00001 // 00002 // StringList.h 00003 // 00004 // StringList: Specialized List containing String objects. 00005 // 00006 // Part of the ht://Dig package <http://www.htdig.org/> 00007 // Copyright (c) 1999, 2000, 2001 The ht://Dig Group 00008 // For copyright details, see the file COPYING in your distribution 00009 // or the GNU General Public License version 2 or later 00010 // <http://www.gnu.org/copyleft/gpl.html> 00011 // 00012 // $Id: StringList_8h-source.html,v 1.1 2008年06月08日 10:12:56 sebdiaz Exp $ 00013 // 00014 00015 #ifndef _StringList_h_ 00016 #define _StringList_h_ 00017 00018 #include "Object.h" 00019 #include "List.h" 00020 #include "htString.h" 00021 00022 00023 class StringList : public List 00024 { 00025 public: 00026 // 00027 // Construction/Destruction 00028 // 00029 StringList(); 00030 00031 // 00032 // Creation of a String from a string or String 00033 // 00034 StringList(const char *str, char sep = '\t') { Create(str, sep); } 00035 StringList(const String &str, char sep = '\t') { Create(str, sep); } 00036 StringList(const char *str, const char *sep) { Create(str, sep); } 00037 StringList(const String &str, const char *sep) { Create(str, sep); } 00038 00039 int Create(const char *str, char sep = '\t'); 00040 int Create(const String &str, char sep = '\t') { return Create(str.get(), sep); } 00041 int Create(const char *str, const char *sep); 00042 int Create(const String &str, const char *sep) { return Create(str.get(), sep); } 00043 00044 // 00045 // Standard List operations... 00046 // 00047 void Add(char *); 00048 void Add(String *obj) { List::Add(obj); } 00049 void Insert(char *, int pos); 00050 void Insert(String *obj, int pos) { List::Insert(obj, pos); } 00051 void Assign(char *, int pos); 00052 void Assign(String *obj, int pos) { List::Assign(obj, pos); } 00053 00054 // 00055 // Since we know we only store strings, we can reliably sort them. 00056 // If direction is 1, the sort will be in descending order 00057 // 00058 void Sort(int direction = 0); 00059 00060 // 00061 // Join the Elements of the StringList together 00062 // 00063 String Join(char) const; 00064 00065 // 00066 // Getting at the parts of the StringList 00067 // 00068 char *operator [] (int n); 00069 00070 private: 00071 }; 00072 00073 #endif