1 // 2 // StringList.h 3 // 4 // StringList: Specialized List containing String objects. 5 // 6 // Part of the ht://Dig package <http://www.htdig.org/> 7 // Copyright (c) 1999-2004 The ht://Dig Group 8 // For copyright details, see the file COPYING in your distribution 9 // or the GNU Library General Public License (LGPL) version 2 or later 10 // <http://www.gnu.org/copyleft/lgpl.html> 11 // 12 // $Id: StringList.h,v 1.12 2004/05/28 13:15:21 lha Exp $ 13 // 14 15 #ifndef _StringList_h_ 16 #define _StringList_h_ 17 18 #include "Object.h" 19 #include "List.h" 20 #include "htString.h" 21 22 23 class StringList : public List 24 { 25 public: 26 // 27 // Construction/Destruction 28 // 29 StringList(); 30 31 // 32 // Creation of a String from a string or String 33 // 34 StringList(const char *str, char sep = '\t') { Create(str, sep); } 35 StringList(const String &str, char sep = '\t') { Create(str, sep); } StringList(const char * str,const char * sep)36 StringList(const char *str, const char *sep) { Create(str, sep); } StringList(const String & str,const char * sep)37 StringList(const String &str, const char *sep) { Create(str, sep); } 38 39 int Create(const char *str, char sep = '\t'); 40 int Create(const String &str, char sep = '\t') { return Create(str.get(), sep); } 41 int Create(const char *str, const char *sep); Create(const String & str,const char * sep)42 int Create(const String &str, const char *sep) { return Create(str.get(), sep); } 43 44 // 45 // Standard List operations... 46 // 47 void Add(const char *); Add(String * obj)48 void Add(String *obj) { List::Add(obj); } 49 void Insert(const char *, int pos); Insert(String * obj,int pos)50 void Insert(String *obj, int pos) { List::Insert(obj, pos); } 51 void Assign(const char *, int pos); Assign(String * obj,int pos)52 void Assign(String *obj, int pos) { List::Assign(obj, pos); } 53 54 // 55 // Since we know we only store strings, we can reliably sort them. 56 // If direction is 1, the sort will be in descending order 57 // 58 void Sort(int direction = 0); 59 60 // 61 // Join the Elements of the StringList together 62 // 63 String Join(char) const; 64 65 // 66 // Getting at the parts of the StringList 67 // 68 char *operator [] (int n); 69 70 private: 71 }; 72 73 #endif 74