00001 // 00002 // aegis - project change supervisor 00003 // Copyright (C) 2004-2008 Peter Miller 00004 // 00005 // This program is free software; you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation; either version 3 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // This program is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with this program. If not, see 00017 // <http://www.gnu.org/licenses/>. 00018 // 00019 00020 #ifndef COMMON_NSTRING_LIST_H 00021 #define COMMON_NSTRING_LIST_H 00022 00023 #include <common/nstring.h> 00024 #include <common/str_list.h> 00025 00030 class nstring_list 00031 { 00032 public: 00039 ~nstring_list() 00040 { 00041 } 00042 00046 nstring_list() 00047 { 00048 } 00049 00053 nstring_list(const nstring_list &arg) : 00054 content(arg.content) 00055 { 00056 } 00057 00061 nstring_list(const string_list_ty &arg) : 00062 content(arg) 00063 { 00064 } 00065 00069 nstring_list &operator=(const nstring_list &); 00070 00075 void 00076 push_back(const nstring &arg) 00077 { 00078 content.push_back(arg.get_ref()); 00079 } 00080 00088 void push_back(const nstring_list &arg); 00089 00094 void 00095 push_back_unique(const nstring &arg) 00096 { 00097 content.push_back_unique(arg.get_ref()); 00098 } 00099 00105 void push_back_unique(const nstring_list &arg); 00106 00111 void 00112 pop_back() 00113 { 00114 content.pop_back(); 00115 } 00116 00121 const nstring 00122 back() 00123 const 00124 { 00125 if (!content.nstrings) 00126 return nstring(); 00127 return nstring(content.string[content.nstrings - 1]); 00128 } 00129 00134 size_t 00135 size() 00136 const 00137 { 00138 return content.nstrings; 00139 } 00140 00145 bool 00146 empty() 00147 const 00148 { 00149 return !content.nstrings; 00150 } 00151 00155 void clear(); 00156 00161 nstring get(int n) const; 00162 00167 nstring 00168 operator[](int n) 00169 const 00170 { 00171 return get(n); 00172 } 00173 00187 void split(const nstring &str, const char *sep = 0, bool ewhite = false); 00188 00193 nstring unsplit(const char *separator = 0) const; 00194 00204 bool member(const nstring &arg) const; 00205 00211 void sort(); 00212 00225 int gmatch_pattern(const nstring &pattern) const; 00226 00238 int gmatch_candidate(const nstring &candidate) const; 00239 00247 void remove(const nstring &arg); 00248 00249 private: 00254 string_list_ty content; 00255 }; 00256 00257 #endif // COMMON_NSTRING_LIST_H