00001 /* 00002 00003 Copyright (C) 1996, 1997 John W. Eaton 00004 00005 This file is part of Octave. 00006 00007 Octave is free software; you can redistribute it and/or modify it 00008 under the terms of the GNU General Public License as published by the 00009 Free Software Foundation; either version 2, or (at your option) any 00010 later version. 00011 00012 Octave is distributed in the hope that it will be useful, but WITHOUT 00013 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00014 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00015 for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with Octave; see the file COPYING. If not, write to the Free 00019 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00020 00021 */ 00022 00023 #if !defined (octave_str_vec_h) 00024 #define octave_str_vec_h 1 00025 00026 #include <iostream> 00027 #include <string> 00028 00029 #include "Array.h" 00030 00031 class 00032 string_vector : public Array<std::string> 00033 { 00034 public: 00035 00036 string_vector (void) : Array<std::string> () { } 00037 00038 explicit string_vector (int n) : Array<std::string> (n) { } 00039 00040 string_vector (const char *s) : Array<std::string> (1, s) { } 00041 00042 string_vector (const std::string& s) : Array<std::string> (1, s) { } 00043 00044 string_vector (const string_vector& s) : Array<std::string> (s) { } 00045 00046 string_vector (const char * const *s); 00047 00048 string_vector (const char * const *s, int n); 00049 00050 string_vector& operator = (const string_vector& s) 00051 { 00052 if (this != &s) 00053 Array<std::string>::operator = (s); 00054 00055 return *this; 00056 } 00057 00058 ~string_vector (void) { } 00059 00060 int empty (void) const { return length () == 0; } 00061 00062 int max_length (void) const 00063 { 00064 int n = length (); 00065 int longest = 0; 00066 00067 for (int i = 0; i < n; i++) 00068 { 00069 int tmp = elem(i).length (); 00070 00071 if (tmp > longest) 00072 longest = tmp; 00073 } 00074 00075 return longest; 00076 } 00077 00078 std::string& operator[] (int i) { return Array<std::string>::elem (i); } 00079 00080 std::string operator[] (int i) const { return Array<std::string>::elem (i); } 00081 00082 static int compare (const void *a_arg, const void *b_arg); 00083 00084 string_vector& qsort (bool make_uniq = false) 00085 { 00086 Array<std::string>::qsort (compare); 00087 00088 if (make_uniq) 00089 uniq (); 00090 00091 return *this; 00092 } 00093 00094 string_vector& uniq (void); 00095 00096 string_vector& append (const std::string& s); 00097 00098 string_vector& append (const string_vector& sv); 00099 00100 char **c_str_vec (void) const; 00101 00102 static void delete_c_str_vec (const char * const*); 00103 00104 std::ostream& list_in_columns (std::ostream&) const; 00105 }; 00106 00107 #endif 00108 00109 /* 00110 ;;; Local Variables: *** 00111 ;;; mode: C++ *** 00112 ;;; End: *** 00113 */
SEO | [PR] 爆速!無料ブログ 無料ホームページ開設 無料ライブ放送 | ||