517
|
1 // oct-obj.cc -*- C++ -*- |
|
2 /* |
|
3 |
1884
|
4 Copyright (C) 1996 John W. Eaton |
517
|
5 |
|
6 This file is part of Octave. |
|
7 |
|
8 Octave is free software; you can redistribute it and/or modify it |
|
9 under the terms of the GNU General Public License as published by the |
|
10 Free Software Foundation; either version 2, or (at your option) any |
|
11 later version. |
|
12 |
|
13 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
16 for more details. |
|
17 |
|
18 You should have received a copy of the GNU General Public License |
|
19 along with Octave; see the file COPYING. If not, write to the Free |
1315
|
20 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
517
|
21 |
|
22 */ |
|
23 |
1297
|
24 #if defined (__GNUG__) |
|
25 #pragma implementation |
|
26 #endif |
|
27 |
517
|
28 #ifdef HAVE_CONFIG_H |
1192
|
29 #include <config.h> |
517
|
30 #endif |
|
31 |
1968
|
32 #include "error.h" |
1742
|
33 #include "oct-obj.h" |
517
|
34 |
1968
|
35 int |
|
36 Octave_object::all_strings (void) const |
|
37 { |
|
38 int n = length (); |
517
|
39 |
1968
|
40 for (int i = 0; i < n; i++) |
|
41 if (! elem(i).is_string ()) |
|
42 return 0; |
1746
|
43 |
1968
|
44 return 1; |
517
|
45 } |
|
46 |
1968
|
47 string_vector |
|
48 Octave_object::make_argv (const string& fcn_name) const |
517
|
49 { |
1968
|
50 string_vector argv; |
|
51 |
|
52 if (all_strings ()) |
|
53 { |
|
54 int n = length (); |
|
55 argv.resize (n+1); |
|
56 argv[0] = fcn_name; |
517
|
57 |
1968
|
58 for (int i = 0; i < n; i++) |
|
59 argv[i+1] = elem(i).string_value (); |
|
60 } |
|
61 else |
|
62 error ("%s: expecting all arguments to be strings", fcn_name.c_str ()); |
517
|
63 |
1968
|
64 return argv; |
517
|
65 } |
|
66 |
|
67 /* |
|
68 ;;; Local Variables: *** |
|
69 ;;; mode: C++ *** |
|
70 ;;; page-delimiter: "^/\\*" *** |
|
71 ;;; End: *** |
|
72 */ |