ZtringList.h Source File

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

# ZtringList.h

Go to the documentation of this file.

    00001 // ZenLib::ZtringList - std::vector<std::(w)string> is better
    00002 // Copyright (C) 2002-2006 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 // ZtringList
    00023 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    00024 //
    00025 // More methods for std::vector<std::(w)string>
    00026 //
    00027 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    00028 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    00029 //
    00030 // 2005-03-25, Zen@MediaArea.net
    00031 // New design
    00032 //
    00033 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    00034
    00035 //---------------------------------------------------------------------------
    00036 #ifndef ZenLib_ZtringListH
    00037 #define ZenLib_ZtringListH
    00038 //---------------------------------------------------------------------------
    00039
    00040 //---------------------------------------------------------------------------
    00041 #include <ZenLib/Ztring.h>
    00042 #include <vector>
    00043 //---------------------------------------------------------------------------
    00044
    00045 namespace ZenLib
    00046 {
    00047
    00048 //***************************************************************************
    00049 /// @brief Vector of strings manipulation (based on std::vector<std::(w)string>)
    00050 //***************************************************************************
    00051
    00052 class ZtringList : public std::vector<Ztring>
    00053 {
    00054 public :
    00055     //Constructors/destructor
    00056     ZtringList ();
    00057     ZtringList (const ZtringList &Source);
    00058     ZtringList (const Ztring &Source);
    00059     ZtringList (const Char *Source);
    00060     #ifdef _UNICODE
    00061     ZtringList (const char *Source); //convert a UTF-8 string into Unicode
    00062     #endif
    00063
    00064     //Operators
    00065     bool        operator == (const ZtringList &Source) const;
    00066     bool        operator != (const ZtringList &Source) const;
    00067     ZtringList &operator += (const ZtringList &Source);
    00068     ZtringList &operator =  (const ZtringList &Source);
    00069
    00070     Ztring     &operator () (size_type Pos); ///< Same as [], but write a empty string if Pos doesn't exist yet
    00071
    00072     //In/out
    00073     Ztring Read () const; /// Read all
    00074     Ztring Read (size_type Pos) const; /// Read a string
    00075     void Write (const Ztring &ToWrite); /// Write all
    00076     void Write (const Ztring &ToWrite, size_type Pos); /// Write a string
    00077     /// @brief Insert a string at position Pos0
    00078     void Insert (const Ztring &ToInsert, size_type Pos0)                           {insert(begin()+Pos0, ToInsert);};
    00079     /// @brief Delete a string at position Pos0
    00080     void Delete (size_type Pos0)                                                   {erase(begin()+Pos0);};
    00081
    00082     //Edition
    00083     /// @brief Swap 2 positions
    00084     void Swap (size_type Pos0_A, size_type Pos0_B);
    00085     /// @brief Sort
    00086     void Sort (ztring_t Options=Ztring_Nothing);
    00087
    00088     //Information
    00089     /// @brief Find the position of the string in the vector
    00090     size_type Find (const Ztring &ToFind, size_type PosBegin=0, const Ztring &Comparator=_T("=="), ztring_t Options=Ztring_Nothing) const;
    00091     /// @brief Return the length of the longest string in the list.
    00092     size_type MaxStringLength_Get ();
    00093
    00094     //Configuration
    00095     /// @brief Set the Separator character
    00096     void Separator_Set (size_type Level, const Ztring &NewSeparator);
    00097     /// @brief Set the Quote character
    00098     /// During Read() or Write() method, if Separator is in the sequence, we must quote it
    00099     void Quote_Set (const Ztring &NewQuote);
    00100
    00101 protected :
    00102     Ztring Separator[1];
    00103     Ztring Quote;
    00104 };
    00105
    00106 } //namespace
    00107 #endif
    00108