00001 // 00002 // aegis - project change supervisor 00003 // Copyright (C) 1995, 2002-2006, 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_WSTR_LIST_H 00021 #define COMMON_WSTR_LIST_H 00022 00023 #include <common/wstr.h> 00024 00039 class wstring_list_ty 00040 { 00041 public: 00048 ~wstring_list_ty(); 00049 00053 wstring_list_ty(); 00054 00058 wstring_list_ty(const wstring_list_ty &); 00059 00063 wstring_list_ty &operator=(const wstring_list_ty &); 00064 00069 size_t size() const { return nitems; } 00070 00075 bool empty() const { return (nitems == 0); } 00076 00085 wstring_ty *get(size_t n) const { return item[n]; } 00086 00095 wstring_ty *operator[](size_t n) const { return get(n); } 00096 00100 void clear(); 00101 00109 void push_back(wstring_ty *arg); 00110 00118 void push_back(const wstring_list_ty &arg); 00119 00123 void pop_back(); 00124 00133 void push_back_unique(wstring_ty *arg); 00134 00142 void push_front(wstring_ty *arg); 00143 00154 bool member(wstring_ty *arg) const; 00155 00164 void remove(wstring_ty *arg); 00165 00179 wstring_ty *unsplit(size_t start, size_t stop, const char *sep = 0) const; 00180 00189 wstring_ty *unsplit(const char *sep = 0) const; 00190 00203 void split(wstring_ty *wis, const char *sep = 0, bool ewhite = false); 00204 00213 bool equal_to(const wstring_list_ty &rhs) const; 00214 00223 bool is_a_subset_of(const wstring_list_ty &rhs) const; 00224 00225 private: 00230 size_t nitems; 00231 00236 size_t nitems_max; 00237 00242 wstring_ty **item; 00243 }; 00244 00245 inline bool 00246 operator==(const wstring_list_ty &lhs, const wstring_list_ty &rhs) 00247 { 00248 return lhs.equal_to(rhs); 00249 } 00250 00251 inline bool 00252 operator!=(const wstring_list_ty &lhs, const wstring_list_ty &rhs) 00253 { 00254 return !lhs.equal_to(rhs); 00255 } 00256 00258 #endif // COMMON_WSTR_LIST_H