00001 /* Copyright (c) MediaArea.net SARL. All Rights Reserved. 00002 * 00003 * Use of this source code is governed by a zlib-style license that can 00004 * be found in the License.txt file in the root of the source tree. 00005 */ 00006 00007 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00008 // 00009 // More methods for std::vector<std::(w)string> 00010 // 00011 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00012 00013 //--------------------------------------------------------------------------- 00014 #ifndef ZenLib_ZtringListH 00015 #define ZenLib_ZtringListH 00016 //--------------------------------------------------------------------------- 00017 00018 //--------------------------------------------------------------------------- 00019 #include "ZenLib/Ztring.h" 00020 #include <vector> 00021 //--------------------------------------------------------------------------- 00022 00023 namespace ZenLib 00024 { 00025 00026 //*************************************************************************** 00027 /// @brief Vector of strings manipulation (based on std::vector<std::(w)string>) 00028 //*************************************************************************** 00029 00030 class ZtringList : public std::vector<Ztring> 00031 { 00032 public : 00033 //Constructors/destructor 00034 ZtringList (); 00035 ZtringList (const ZtringList &Source); 00036 ZtringList (const Ztring &Source); 00037 ZtringList (const Char *Source); 00038 #ifdef _UNICODE 00039 ZtringList (const char *Source); //convert a UTF-8 string into Unicode 00040 #endif 00041 00042 //Operators 00043 bool operator == (const ZtringList &Source) const; 00044 bool operator != (const ZtringList &Source) const; 00045 ZtringList &operator += (const ZtringList &Source); 00046 ZtringList &operator = (const ZtringList &Source); 00047 00048 Ztring &operator () (size_type Pos); ///< Same as [], but write a empty string if Pos doesn't exist yet 00049 00050 //In/out 00051 Ztring Read () const; /// Read all 00052 const Ztring &Read (size_type Pos) const; /// Read a string 00053 void Write (const Ztring &ToWrite); /// Write all 00054 void Write (const Ztring &ToWrite, size_type Pos); /// Write a string 00055 /// @brief Insert a string at position Pos0 00056 void Insert (const Ztring &ToInsert, size_type Pos0) {insert(begin()+Pos0, ToInsert);}; 00057 /// @brief Delete a string at position Pos0 00058 void Delete (size_type Pos0) {erase(begin()+Pos0);}; 00059 00060 //Edition 00061 /// @brief Swap 2 positions 00062 void Swap (size_type Pos0_A, size_type Pos0_B); 00063 /// @brief Sort 00064 void Sort (ztring_t Options=Ztring_Nothing); 00065 00066 //Information 00067 /// @brief Find the position of the string in the vector 00068 size_type Find (const Ztring &ToFind, size_type PosBegin=0, const Ztring &Comparator=__T("=="), ztring_t Options=Ztring_Nothing) const; 00069 /// @brief Return the length of the longest string in the list. 00070 size_type MaxStringLength_Get (); 00071 00072 //Configuration 00073 /// @brief Set the Separator character 00074 void Separator_Set (size_type Level, const Ztring &NewSeparator); 00075 /// @brief Set the Quote character 00076 /// During Read() or Write() method, if Separator is in the sequence, we must quote it 00077 void Quote_Set (const Ztring &NewQuote); 00078 /// @brief Set the Maximum number of element to read 00079 /// During Read() or Write() method, if there is more elements, merge them with the last element 00080 void Max_Set (size_type Level, size_type Max_New); 00081 00082 protected : 00083 Ztring Separator[1]; 00084 Ztring Quote; 00085 size_type Max[1]; 00086 }; 00087 00088 } //namespace 00089 #endif