00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __UT_StringArray_h__
00021 #define __UT_StringArray_h__
00022
00023 #include "UT_API.h"
00024 #include <string>
00025 #include <vector>
00026 #include "UT_RefArray.h"
00027 #include "UT_String.h"
00028
00029
00030 class UT_API UT_StringArray {
00031 public:
00032 typedef int (*Comparator)(const UT_String *, const UT_String *s2);
00033
00034 UT_StringArray();
00035 explicit UT_StringArray(const char **src);
00036 UT_StringArray(const UT_StringArray &src);
00037
00038 ~UT_StringArray();
00039
00040
00041 void merge( UT_StringArray &other );
00042 int append(const char *str);
00043 int insert(const char *str, int idx);
00044 int remove(int idx);
00045 void removeLast();
00046 void clear();
00047
00048
00049 void resize(int nsize);
00050 int entries() const;
00051 int capacity() const
00052 { return myStrings.capacity(); }
00053
00054
00055 void fromStdVectorOfStrings(
00056 const std::vector<std::string> &vec);
00057 void toStdVectorOfStrings(
00058 std::vector<std::string> &vec) const;
00059
00060 const UT_StringArray &operator=(const UT_StringArray &src);
00061 UT_String &operator()(int idx);
00062 const UT_String &operator()(int idx) const;
00063 UT_String &last();
00064 const UT_String &last() const;
00065 bool operator==(const UT_StringArray &src) const;
00066 bool operator!=(const UT_StringArray &src) const;
00067
00068 int find(const char *str, unsigned int s=0) const;
00069
00070 void sort(bool forward, bool numbered);
00071
00072
00073
00074
00075
00076 void sort() { sort(true, true); }
00077
00078
00079 void sort(Comparator compare);
00080
00081 int sortedInsert(const char *str,
00082 bool forward = true,
00083 bool numbered = true);
00084 int sortedFind(const char *str,
00085 bool forward = true,
00086 bool numbered = true) const;
00087
00088 int getLongestPrefixLength() const;
00089
00090
00091
00092 void join(const char *sep, UT_String &result) const;
00093
00094
00095
00096
00097 unsigned hash() const;
00098
00099 private:
00100 UT_RefArray<UT_String> myStrings;
00101 };
00102
00103 #endif