Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #if !defined (octave_str_vec_h)
00024 #define octave_str_vec_h 1
00025
00026 #include <iosfwd>
00027 #include <list>
00028 #include <set>
00029 #include <string>
00030
00031 #include "Array.h"
00032
00033 class
00034 OCTAVE_API
00035 string_vector : public Array<std::string>
00036 {
00037 public:
00038
00039 string_vector (void) : Array<std::string> () { }
00040
00041 explicit string_vector (octave_idx_type n)
00042 : Array<std::string> (dim_vector (n, 1)) { }
00043
00044 string_vector (const char *s)
00045 : Array<std::string> (dim_vector (1, 1), s) { }
00046
00047 string_vector (const std::string& s)
00048 : Array<std::string> (dim_vector (1, 1), s) { }
00049
00050 string_vector (const string_vector& s) : Array<std::string> (s) { }
00051
00052 string_vector (const std::list<std::string>& lst);
00053
00054 string_vector (const std::set<std::string>& lst);
00055
00056 string_vector (const Array<std::string>& s)
00057 : Array<std::string> (s.as_column ()) { }
00058
00059 string_vector (const char * const *s);
00060
00061 string_vector (const char * const *s, octave_idx_type n);
00062
00063 string_vector& operator = (const string_vector& s)
00064 {
00065 if (this != &s)
00066 Array<std::string>::operator = (s);
00067
00068 return *this;
00069 }
00070
00071 ~string_vector (void) { }
00072
00073 bool empty (void) const { return length () == 0; }
00074
00075 octave_idx_type max_length (void) const
00076 {
00077 octave_idx_type n = length ();
00078 octave_idx_type longest = 0;
00079
00080 for (octave_idx_type i = 0; i < n; i++)
00081 {
00082 octave_idx_type tmp = elem(i).length ();
00083
00084 if (tmp > longest)
00085 longest = tmp;
00086 }
00087
00088 return longest;
00089 }
00090
00091 void resize (octave_idx_type n, const std::string& rfv = resize_fill_value ())
00092 {
00093 Array<std::string>::resize (dim_vector (n, 1), rfv);
00094 }
00095
00096 std::string& operator[] (octave_idx_type i) { return Array<std::string>::elem (i); }
00097
00098 std::string operator[] (octave_idx_type i) const { return Array<std::string>::elem (i); }
00099
00100 string_vector& sort (bool make_uniq = false);
00101
00102 string_vector& uniq (void);
00103
00104 string_vector& append (const std::string& s);
00105
00106 string_vector& append (const string_vector& sv);
00107
00108 std::string join (const std::string& sep = std::string ()) const;
00109
00110 char **c_str_vec (void) const;
00111
00112 static void delete_c_str_vec (const char * const*);
00113
00114 std::ostream& list_in_columns (std::ostream&, int width = 0) const;
00115 };
00116
00117 #endif