Mercurial > hg > octave-lyh
annotate liboctave/str-vec.h @ 11188:4cb1522e4d0f
Use function handle as input to cellfun,
rather than quoted function name or anonymous function wrapper.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Wed, 03 Nov 2010 17:20:56 -0700 |
parents | a6b64a7a3769 |
children | fd0a3ac60b0e |
rev | line source |
---|---|
1757 | 1 /* |
2 | |
8920 | 3 Copyright (C) 1996, 1997, 2000, 2002, 2003, 2005, 2006, 2007, 2009 |
7017 | 4 John W. Eaton |
1757 | 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 | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
1757 | 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 | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
1757 | 21 |
22 */ | |
23 | |
24 #if !defined (octave_str_vec_h) | |
25 #define octave_str_vec_h 1 | |
26 | |
8950
d865363208d6
include <iosfwd> instead of <iostream> in header files
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
27 #include <iosfwd> |
5880 | 28 #include <list> |
9582
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
29 #include <set> |
1757 | 30 #include <string> |
31 | |
32 #include "Array.h" | |
33 | |
34 class | |
6108 | 35 OCTAVE_API |
3504 | 36 string_vector : public Array<std::string> |
1757 | 37 { |
38 public: | |
1879 | 39 |
3504 | 40 string_vector (void) : Array<std::string> () { } |
1879 | 41 |
10355
f9347eac65dc
make string_vector be a column vector as it used to be
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
42 explicit string_vector (octave_idx_type n) : Array<std::string> (n, 1) { } |
1879 | 43 |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
44 string_vector (const char *s) : Array<std::string> (1, 1, s) { } |
1879 | 45 |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
46 string_vector (const std::string& s) : Array<std::string> (1, 1, s) { } |
1879 | 47 |
3504 | 48 string_vector (const string_vector& s) : Array<std::string> (s) { } |
1757 | 49 |
5880 | 50 string_vector (const std::list<std::string>& lst); |
51 | |
9582
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
52 string_vector (const std::set<std::string>& lst); |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
53 |
10492
a6b64a7a3769
make feval work with overloaded handles
Jaroslav Hajek <highegg@gmail.com>
parents:
10355
diff
changeset
|
54 string_vector (const Array<std::string>& s) |
a6b64a7a3769
make feval work with overloaded handles
Jaroslav Hajek <highegg@gmail.com>
parents:
10355
diff
changeset
|
55 : Array<std::string> (s.as_column ()) { } |
a6b64a7a3769
make feval work with overloaded handles
Jaroslav Hajek <highegg@gmail.com>
parents:
10355
diff
changeset
|
56 |
2493 | 57 string_vector (const char * const *s); |
58 | |
5275 | 59 string_vector (const char * const *s, octave_idx_type n); |
2493 | 60 |
1757 | 61 string_vector& operator = (const string_vector& s) |
2941 | 62 { |
63 if (this != &s) | |
3504 | 64 Array<std::string>::operator = (s); |
1879 | 65 |
2941 | 66 return *this; |
67 } | |
1757 | 68 |
69 ~string_vector (void) { } | |
70 | |
6379 | 71 bool empty (void) const { return length () == 0; } |
1757 | 72 |
5275 | 73 octave_idx_type max_length (void) const |
2941 | 74 { |
5275 | 75 octave_idx_type n = length (); |
76 octave_idx_type longest = 0; | |
1757 | 77 |
5275 | 78 for (octave_idx_type i = 0; i < n; i++) |
2941 | 79 { |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
80 octave_idx_type tmp = elem(i).length (); |
1757 | 81 |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
82 if (tmp > longest) |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
83 longest = tmp; |
2941 | 84 } |
1757 | 85 |
2941 | 86 return longest; |
87 } | |
1757 | 88 |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
89 void resize (octave_idx_type n, const std::string& rfv = resize_fill_value ()) |
10355
f9347eac65dc
make string_vector be a column vector as it used to be
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
90 { Array<std::string>::resize (n, 1, rfv); } |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
91 |
5275 | 92 std::string& operator[] (octave_idx_type i) { return Array<std::string>::elem (i); } |
1757 | 93 |
5275 | 94 std::string operator[] (octave_idx_type i) const { return Array<std::string>::elem (i); } |
1757 | 95 |
8678
e2b4c19c455c
redo changeset 4238f2600a17 with fixes to sorting
Jaroslav Hajek <highegg@gmail.com>
parents:
8671
diff
changeset
|
96 string_vector& sort (bool make_uniq = false); |
2941 | 97 |
98 string_vector& uniq (void); | |
1811 | 99 |
4392 | 100 string_vector& append (const std::string& s); |
101 | |
102 string_vector& append (const string_vector& sv); | |
103 | |
2937 | 104 char **c_str_vec (void) const; |
105 | |
106 static void delete_c_str_vec (const char * const*); | |
107 | |
5690 | 108 std::ostream& list_in_columns (std::ostream&, int width = 0) const; |
1757 | 109 }; |
110 | |
111 #endif |