Octave-Forge - Extra packages for GNU Octave | |
Home · Packages · Developers · Documentation · FAQ · Bugs · Mailing Lists · Links · Code |
00001 /* 00002 00003 Copyright (C) 1996, 1997, 2000, 2002, 2003, 2005, 2006, 2007, 2009 00004 John W. Eaton 00005 00006 This file is part of Octave. 00007 00008 Octave is free software; you can redistribute it and/or modify it 00009 under the terms of the GNU General Public License as published by the 00010 Free Software Foundation; either version 3 of the License, or (at your 00011 option) any later version. 00012 00013 Octave is distributed in the hope that it will be useful, but WITHOUT 00014 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00015 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00016 for more details. 00017 00018 You should have received a copy of the GNU General Public License 00019 along with Octave; see the file COPYING. If not, see 00020 <http://www.gnu.org/licenses/>. 00021 00022 */ 00023 00024 #if !defined (octave_str_vec_h) 00025 #define octave_str_vec_h 1 00026 00027 #include <iosfwd> 00028 #include <list> 00029 #include <set> 00030 #include <string> 00031 00032 #include "Array.h" 00033 00034 class 00035 OCTAVE_API 00036 string_vector : public Array<std::string> 00037 { 00038 public: 00039 00040 string_vector (void) : Array<std::string> () { } 00041 00042 explicit string_vector (octave_idx_type n) : Array<std::string> (n) { } 00043 00044 string_vector (const char *s) : Array<std::string> (1, s) { } 00045 00046 string_vector (const std::string& s) : Array<std::string> (1, s) { } 00047 00048 string_vector (const string_vector& s) : Array<std::string> (s) { } 00049 00050 string_vector (const std::list<std::string>& lst); 00051 00052 string_vector (const std::set<std::string>& lst); 00053 00054 string_vector (const char * const *s); 00055 00056 string_vector (const char * const *s, octave_idx_type n); 00057 00058 string_vector& operator = (const string_vector& s) 00059 { 00060 if (this != &s) 00061 Array<std::string>::operator = (s); 00062 00063 return *this; 00064 } 00065 00066 ~string_vector (void) { } 00067 00068 bool empty (void) const { return length () == 0; } 00069 00070 octave_idx_type max_length (void) const 00071 { 00072 octave_idx_type n = length (); 00073 octave_idx_type longest = 0; 00074 00075 for (octave_idx_type i = 0; i < n; i++) 00076 { 00077 octave_idx_type tmp = elem(i).length (); 00078 00079 if (tmp > longest) 00080 longest = tmp; 00081 } 00082 00083 return longest; 00084 } 00085 00086 std::string& operator[] (octave_idx_type i) { return Array<std::string>::elem (i); } 00087 00088 std::string operator[] (octave_idx_type i) const { return Array<std::string>::elem (i); } 00089 00090 string_vector& sort (bool make_uniq = false); 00091 00092 string_vector& uniq (void); 00093 00094 string_vector& append (const std::string& s); 00095 00096 string_vector& append (const string_vector& sv); 00097 00098 char **c_str_vec (void) const; 00099 00100 static void delete_c_str_vec (const char * const*); 00101 00102 std::ostream& list_in_columns (std::ostream&, int width = 0) const; 00103 }; 00104 00105 #endif 00106 00107 /* 00108 ;;; Local Variables: *** 00109 ;;; mode: C++ *** 00110 ;;; End: *** 00111 */