ZtringListList.h

Go to the documentation of this file.
00001 // ZenLib::ZtringListList - More methods for std::vector<std::vector<std::(w)string>>
00002 // Copyright (C) 2002-2005 Jerome Martinez, Zen@MediaArea.net
00003 //
00004 // This software is provided 'as-is', without any express or implied
00005 // warranty.  In no event will the authors be held liable for any damages
00006 // arising from the use of this software.
00007 //
00008 // Permission is granted to anyone to use this software for any purpose,
00009 // including commercial applications, and to alter it and redistribute it
00010 // freely, subject to the following restrictions:
00011 //
00012 // 1. The origin of this software must not be misrepresented; you must not
00013 //    claim that you wrote the original software. If you use this software
00014 //    in a product, an acknowledgment in the product documentation would be
00015 //    appreciated but is not required.
00016 // 2. Altered source versions must be plainly marked as such, and must not be
00017 //    misrepresented as being the original software.
00018 // 3. This notice may not be removed or altered from any source distribution.
00019 //
00020 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00021 //
00022 // More methods for std::vector<std::vector<std::(w)string>>
00023 //
00024 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00025 
00026 //---------------------------------------------------------------------------
00027 #ifndef ZenLib_ZtringListListH
00028 #define ZenLib_ZtringListListH
00029 //---------------------------------------------------------------------------
00030 
00031 //---------------------------------------------------------------------------
00032 #include "ZenLib/ZtringList.h"
00033 //---------------------------------------------------------------------------
00034 
00035 namespace ZenLib
00036 {
00037 
00038 //***************************************************************************
00039 /// @brief Vector of vectors of strings manipulation (based on std::vector<std::vector<std::(w)string>>)
00040 //***************************************************************************
00041 
00042 class ZtringListList : public std::vector<ZtringList>
00043 {
00044 public :
00045     //Constructors/Destructor
00046     ZtringListList ();
00047     ZtringListList (const ZtringListList &Source);
00048     ZtringListList (const Ztring &Source);
00049     ZtringListList (const Char *Source);
00050     #ifdef _UNICODE
00051     ZtringListList (const char *Source); //convert a UTF-8 string into Unicode
00052     #endif
00053 
00054     //Operateurs
00055     bool            operator == (const ZtringListList &Source) const;
00056     bool            operator != (const ZtringListList &Source) const;
00057     ZtringListList &operator += (const ZtringListList &Source);
00058     ZtringListList &operator =  (const ZtringListList &Source);
00059 
00060     ZtringList     &operator () (size_type Pos0); ///< Same as [], but write a empty string if Pos doesn't exist yet
00061     Ztring         &operator () (size_type Pos0, size_type Pos1);
00062     /// @brief Return [Pos][Pos1], Pos=First occurency of Pos0 in [xxx][0]
00063     Ztring         &operator () (const Ztring &Pos0, size_type Pos1=1)             {return operator() (Pos0, 0 , Pos1);};
00064     /// @brief Return [Pos][Pos1], Pos=First occurency of Pos0 in [xxx][Pos0_1]
00065     Ztring         &operator () (const Ztring &Pos0, size_type Pos0_1, size_type Pos1);
00066 
00067     //In/Out
00068     /// @brief Read all
00069     Ztring Read () const;
00070     /// @brief Read a vector of string
00071     Ztring Read (size_type Pos0) const;
00072     /// @brief Read a string
00073     const Ztring &Read (size_type Pos0, size_type Pos1) const;
00074     /// @brief Return [Pos][Pos1], Pos=First occurency of Pos0 in [xxx][0]
00075     const Ztring &Read (const Ztring &Pos0, size_type Pos1=1) const;
00076     /// @brief Return [Pos][Pos1], Pos=First occurency of Pos0 in [xxx][Pos0_1]
00077     const Ztring &Read (const Ztring &Pos0, size_type Pos0_1, size_type Pos1) const;
00078     /// @brief Return [Pos][Pos1], Pos=First occurency of Pos0 in [xxx][0], with default value
00079     const Ztring &Read (const Ztring &Pos0, const Ztring &Default, size_type Pos1=1) const;
00080     /// @brief Return [Pos][Pos1], Pos=First occurency of Pos0 in [xxx][Pos0_1], with default value
00081     const Ztring &Read (const Ztring &Pos0, const Ztring &Default, size_type Pos0_1, size_type Pos1) const;
00082     /// @brief Read all strings at position Pos1
00083     Ztring Read1 (size_type Pos1) const;
00084 
00085     /// @brief Write all
00086     void Write (const Ztring &ToWrite);
00087     /// @brief Write a vector of string
00088     void Write (const ZtringList &ToWrite, size_type Pos0);
00089     /// @brief Write a vector of string
00090     void Write (const Ztring &ToWrite, size_type Pos0, size_type Pos1);
00091     /// @brief Add a vector of string
00092     void push_back (const ZtringList &ToAdd);
00093     /// @brief Add a vector of string (with separator is ZtringListList Separator)
00094     void push_back (const Ztring &ToAdd);
00095     /// @brief Add a vector of string (Char version)
00096     void push_back (const Char* ToAdd)                                          {push_back(Ztring(ToAdd));};
00097     /// @brief Insert a vector of string at position Pos0
00098     void Insert (const ZtringList &ToInsert, size_type Pos0)                       {insert(begin()+Pos0, ToInsert);};
00099     /// @brief Insert a string at all positions Pos1
00100     void Insert1 (const Ztring &ToInsert, size_type Pos1);
00101     /// @brief Delete a vector of string at position Pos0
00102     void Delete (size_type Pos0)                                                   {erase(begin()+Pos0);};
00103     /// @brief Delete all vectors of string, with [xxx][Pos1] == ToFind
00104     void Delete (const Ztring &ToFind, size_type Pos1=0, const Ztring &Comparator=_T("=="), ztring_t Options=Ztring_Nothing);
00105     /// @brief Delete a string at all positions Pos1
00106     void Delete1 (size_type Pos1);
00107 
00108     //Edition
00109     /// @brief Swap 2 positions
00110     void Swap (size_type Pos0_A, size_type Pos0_B);
00111     /// @brief Swap 2 columns for each line
00112     void Swap1 (size_type Pos1_A, size_type Pos1_B);
00113     /// @brief Sort
00114     void Sort (size_type Pos1, ztring_t Options=Ztring_Nothing);
00115 
00116     //Information
00117     /// @brief Find the first position of the string in the vector of vector, in a specific column
00118     size_type Find (const Ztring &ToFind, size_type Pos1=0, size_type Pos0Begin=0) const;
00119     /// @brief Find the first position of the string in the vector of vector, in a specific column, which is not empty
00120     size_type Find_Filled (size_type Pos1=0, size_type Pos0Begin=0) const;
00121     /// @brief Find the first position of the string in the vector of vector, in a specific column
00122     size_type Find (const Ztring &ToFind, size_type Pos1, size_type Pos0Begin, const Ztring &Comparator, ztring_t Options=Ztring_Nothing) const;
00123     /// @brief Return [xxx][Pos1Value] when founded the first position of the string in the vector of vector, in a specific column
00124     Ztring FindValue (const Ztring &ToFind, size_type Pos1Value=1, size_type Pos1=0, size_type Pos0Begin=0, const Ztring &Comparator=_T("=="), ztring_t Options=Ztring_Nothing) const;
00125     /// @brief Return a subsheet, with all lines with position of the string in the vector of vector, in a specific column
00126     ZtringListList SubSheet (const Ztring &ToFind, size_type Pos1=0, size_type Pos0Begin=0, const Ztring &Comparator=_T("=="), ztring_t Options=Ztring_Nothing) const;
00127 
00128     //Configuration
00129     /// @brief Set the Separator character
00130     void Separator_Set (size_type Level, const Ztring &NewSeparator);
00131     /// @brief Set the Quote character
00132     /// During Read() or Write() method, if Separator is in the sequence, we must quote it
00133     void Quote_Set (const Ztring &NewQuote);
00134     /// @brief Set the Maximum number of element to read
00135     /// During Read() or Write() method, if there is more elements, merge them with the last element
00136     void Max_Set (size_type Level, size_type Max);
00137 
00138 protected :
00139     Ztring Separator[2];
00140     Ztring Quote;
00141     size_type Max[2];
00142 };
00143 
00144 } //namespace
00145 #endif
00146 

Generated on Fri Mar 20 09:24:08 2009 for ZenLib by  doxygen 1.4.7