ZenLib
ZtringList.h
Go to the documentation of this file.
1 /* Copyright (c) MediaArea.net SARL. All Rights Reserved.
2  *
3  * Use of this source code is governed by a zlib-style license that can
4  * be found in the License.txt file in the root of the source tree.
5  */
6 
7 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
8 //
9 // More methods for std::vector<std::(w)string>
10 //
11 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
12 
13 //---------------------------------------------------------------------------
14 #ifndef ZenLib_ZtringListH
15 #define ZenLib_ZtringListH
16 //---------------------------------------------------------------------------
17 
18 //---------------------------------------------------------------------------
19 #include "ZenLib/Ztring.h"
20 #include <vector>
21 //---------------------------------------------------------------------------
22 
23 namespace ZenLib
24 {
25 
26 //***************************************************************************
27 /// @brief Vector of strings manipulation (based on std::vector<std::(w)string>)
28 //***************************************************************************
29 
30 class ZtringList : public std::vector<Ztring>
31 {
32 public :
33  //Constructors/destructor
34  ZtringList ();
35  ZtringList (const ZtringList &Source);
36  ZtringList (const Ztring &Source);
37  ZtringList (const Char *Source);
38  #ifdef _UNICODE
39  ZtringList (const char *Source); //convert a UTF-8 string into Unicode
40  #endif
41 
42  //Operators
43  bool operator == (const ZtringList &Source) const;
44  bool operator != (const ZtringList &Source) const;
45  ZtringList &operator += (const ZtringList &Source);
46  ZtringList &operator = (const ZtringList &Source);
47 
48  Ztring &operator () (size_type Pos); ///< Same as [], but write a empty string if Pos doesn't exist yet
49 
50  //In/out
51  Ztring Read () const; /// Read all
52  const Ztring &Read (size_type Pos) const; /// Read a string
53  void Write (const Ztring &ToWrite); /// Write all
54  void Write (const Ztring &ToWrite, size_type Pos); /// Write a string
55  /// @brief Insert a string at position Pos0
56  void Insert (const Ztring &ToInsert, size_type Pos0) {insert(begin()+Pos0, ToInsert);};
57  /// @brief Delete a string at position Pos0
58  void Delete (size_type Pos0) {erase(begin()+Pos0);};
59 
60  //Edition
61  /// @brief Swap 2 positions
62  void Swap (size_type Pos0_A, size_type Pos0_B);
63  /// @brief Sort
64  void Sort (ztring_t Options=Ztring_Nothing);
65 
66  //Information
67  /// @brief Find the position of the string in the vector
68  size_type Find (const Ztring &ToFind, size_type PosBegin=0, const Ztring &Comparator=__T("=="), ztring_t Options=Ztring_Nothing) const;
69  /// @brief Return the length of the longest string in the list.
70  size_type MaxStringLength_Get ();
71 
72  //Configuration
73  /// @brief Set the Separator character
74  void Separator_Set (size_type Level, const Ztring &NewSeparator);
75  /// @brief Set the Quote character
76  /// During Read() or Write() method, if Separator is in the sequence, we must quote it
77  void Quote_Set (const Ztring &NewQuote);
78  /// @brief Set the Maximum number of element to read
79  /// During Read() or Write() method, if there is more elements, merge them with the last element
80  void Max_Set (size_type Level, size_type Max_New);
81 
82 protected :
85  size_type Max[1];
86 };
87 
88 } //namespace
89 #endif
char Char
Definition: Conf.h:215
ZtringList & operator+=(const ZtringList &Source)
Definition: Ztring.h:35
void Separator_Set(size_type Level, const Ztring &NewSeparator)
Set the Separator character.
bool operator==(const ZtringList &Source) const
Ztring & operator()(size_type Pos)
Same as [], but write a empty string if Pos doesn&#39;t exist yet.
Definition: BitStream.h:23
bool operator!=(const ZtringList &Source) const
void Max_Set(size_type Level, size_type Max_New)
Set the Maximum number of element to read During Read() or Write() method, if there is more elements...
Ztring Read() const
void Delete(size_type Pos0)
Delete a string at position Pos0.
Definition: ZtringList.h:58
Vector of strings manipulation (based on std::vector<std::(w)string>)
Definition: ZtringList.h:30
Ztring Separator[1]
Definition: ZtringList.h:83
void Quote_Set(const Ztring &NewQuote)
Set the Quote character During Read() or Write() method, if Separator is in the sequence, we must quote it.
ztring_t
Options for Ztring methods.
Definition: Ztring.h:33
void Swap(size_type Pos0_A, size_type Pos0_B)
Swap 2 positions.
size_type Find(const Ztring &ToFind, size_type PosBegin=0, const Ztring &Comparator=__T("=="), ztring_t Options=Ztring_Nothing) const
Find the position of the string in the vector.
void Write(const Ztring &ToWrite)
Read a string.
void Sort(ztring_t Options=Ztring_Nothing)
Sort.
String manipulation (based on std::(w)string)
Definition: Ztring.h:49
#define __T(__x)
Definition: Conf.h:217
ZtringList & operator=(const ZtringList &Source)
void Insert(const Ztring &ToInsert, size_type Pos0)
Insert a string at position Pos0.
Definition: ZtringList.h:56
size_type MaxStringLength_Get()
Return the length of the longest string in the list.
Ztring Quote
Definition: ZtringList.h:84
size_type Max[1]
Definition: ZtringList.h:85