ZtringListList.h Source File

Main Page Namespace List Class Hierarchy Compound List File List Namespace Members Compound Members File Members

# ZtringListList.h

Go to the documentation of this file.

    00001 // ZenLib::ZtringListList - std::vector<std::vector<std::(w)string>> is better
    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 //
    00023 // More methods for std::vector<std::vector<std::(w)string>>
    00024 //
    00025 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    00026 //
    00027 // 2005-03-25, Zen@MediaArea.net
    00028 // New design
    00029 //
    00030 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    00031 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    00032
    00033 //---------------------------------------------------------------------------
    00034 #ifndef ZenLib_ZtringListListH
    00035 #define ZenLib_ZtringListListH
    00036 //---------------------------------------------------------------------------
    00037
    00038 //---------------------------------------------------------------------------
    00039 #include <ZenLib/ZtringList.h>
    00040 //---------------------------------------------------------------------------
    00041
    00042 namespace ZenLib
    00043 {
    00044
    00045 //***************************************************************************
    00046 /// @brief Vector of vectors of strings manipulation (based on std::vector<std::vector<std::(w)string>>)
    00047 //***************************************************************************
    00048
    00049 class ZtringListList : public std::vector<ZtringList>
    00050 {
    00051 public :
    00052     //Constructors/Destructor
    00053     ZtringListList ();
    00054     ZtringListList (const ZtringListList &Source);
    00055     ZtringListList (const Ztring &Source);
    00056     ZtringListList (const Char *Source);
    00057     #ifdef _UNICODE
    00058     ZtringListList (const char *Source); //convert a UTF-8 string into Unicode
    00059     #endif
    00060
    00061     //Operateurs
    00062     bool            operator == (const ZtringListList &Source) const;
    00063     bool            operator != (const ZtringListList &Source) const;
    00064     ZtringListList &operator += (const ZtringListList &Source);
    00065     ZtringListList &operator =  (const ZtringListList &Source);
    00066
    00067     ZtringList     &operator () (size_t Pos0); ///< Same as [], but write a empty string if Pos doesn't exist yet
    00068     Ztring         &operator () (size_t Pos0, size_t Pos1);
    00069     /// @brief Return [Pos][Pos1], Pos=First occurency of Pos0 in [xxx][0]
    00070     Ztring         &operator () (const Ztring &Pos0, size_t Pos1=1)             {return operator() (Pos0, 0 , Pos1);};
    00071     /// @brief Return [Pos][Pos1], Pos=First occurency of Pos0 in [xxx][Pos0_1]
    00072     Ztring         &operator () (const Ztring &Pos0, size_t Pos0_1, size_t Pos1);
    00073
    00074     //In/Out
    00075     /// @brief Read all
    00076     Ztring Read () const;
    00077     /// @brief Read a vector of string
    00078     Ztring Read (size_t Pos0) const;
    00079     /// @brief Read a string
    00080     Ztring Read (size_t Pos0, size_t Pos1) const;
    00081     /// @brief Return [Pos][Pos1], Pos=First occurency of Pos0 in [xxx][0]
    00082     Ztring Read (const Ztring &Pos0, size_t Pos1=1) const       {return Read(Pos0, 0 , Pos1);};
    00083     /// @brief Return [Pos][Pos1], Pos=First occurency of Pos0 in [xxx][Pos0_1]
    00084     Ztring Read (const Ztring &Pos0, size_t Pos0_1, size_t Pos1) const          {return Read(Pos0, _T(""), 0 , Pos1);};
    00085     /// @brief Return [Pos][Pos1], Pos=First occurency of Pos0 in [xxx][0], with default value
    00086     Ztring Read (const Ztring &Pos0, Ztring Default, size_t Pos1=1) const       {return Read(Pos0, Default, 0 , Pos1);};
    00087     /// @brief Return [Pos][Pos1], Pos=First occurency of Pos0 in [xxx][Pos0_1], with default value
    00088     Ztring Read (const Ztring &Pos0, Ztring Default, size_t Pos0_1, size_t Pos1) const;
    00089     /// @brief Read all strings at position Pos1
    00090     Ztring Read1 (size_t Pos1) const;
    00091
    00092     /// @brief Write all
    00093     void Write (const Ztring &ToWrite);
    00094     /// @brief Write a vector of string
    00095     void Write (const ZtringList &ToWrite, size_t Pos0);
    00096     /// @brief Write a vector of string
    00097     void Write (const Ztring &ToWrite, size_t Pos0, size_t Pos1);
    00098     /// @brief Add a vector of string
    00099     void push_back (const ZtringList &ToAdd);
    00100     /// @brief Add a vector of string (with separator is ZtringListList Separator)
    00101     void push_back (const Ztring &ToAdd);
    00102     /// @brief Add a vector of string (Char version)
    00103     void push_back (const Char* ToAdd)                                          {push_back(Ztring(ToAdd));};
    00104     /// @brief Insert a vector of string at position Pos0
    00105     void Insert (const ZtringList &ToInsert, size_t Pos0)                       {insert(begin()+Pos0, ToInsert);};
    00106     /// @brief Insert a string at all positions Pos1
    00107     void Insert1 (const Ztring &ToInsert, size_t Pos1);
    00108     /// @brief Delete a vector of string at position Pos0
    00109     void Delete (size_t Pos0)                                                   {erase(begin()+Pos0);};
    00110     /// @brief Delete all vectors of string, with [xxx][Pos1] == ToFind
    00111     void Delete (const Ztring &ToFind, size_t Pos1=0, const Ztring &Comparator=_T("=="), ztring_t Options=Ztring_Nothing);
    00112     /// @brief Delete a string at all positions Pos1
    00113     void Delete1 (size_t Pos1);
    00114
    00115     //Edition
    00116     /// @brief Swap 2 positions
    00117     void Swap (size_t Pos0_A, size_t Pos0_B);
    00118     /// @brief Swap 2 columns for each line
    00119     void Swap1 (size_t Pos1_A, size_t Pos1_B);
    00120     /// @brief Sort
    00121     void Sort (size_t Pos1, ztring_t Options=Ztring_Nothing);
    00122
    00123     //Information
    00124     /// @brief Find the first position of the string in the vector of vector, in a specific column
    00125     size_t Find (const Ztring &ToFind, size_t Pos1=0, size_t Pos0Begin=0, const Ztring &Comparator=_T("=="), ztring_t Options=Ztring_Nothing) const;
    00126     /// @brief Return [xxx][Pos1Value] when founded the first position of the string in the vector of vector, in a specific column
    00127     Ztring FindValue (const Ztring &ToFind, size_t Pos1Value=1, size_t Pos1=0, size_t Pos0Begin=0, const Ztring &Comparator=_T("=="), ztring_t Options=Ztring_Nothing) const;
    00128     /// @brief Return a subsheet, with all lines with position of the string in the vector of vector, in a specific column
    00129     ZtringListList SubSheet (const Ztring &ToFind, size_t Pos1=0, size_t Pos0Begin=0, const Ztring &Comparator=_T("=="), ztring_t Options=Ztring_Nothing) const;
    00130
    00131     //Configuration
    00132     /// @brief Set the Separator character
    00133     void Separator_Set (size_t Level, const Ztring &NewSeparator);
    00134     /// @brief Set the Quote character
    00135     /// During Read() or Write() method, if Separator is in the sequence, we must quote it
    00136     void Quote_Set (const Ztring &NewQuote);
    00137
    00138 protected :
    00139     Ztring Separator[2];
    00140     Ztring Quote;
    00141 };
    00142
    00143 } //namespace
    00144 #endif
    00145