ZenLib

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

ZtringListList.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::vector<std::(w)string>>
10 //
11 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
12
13 //---------------------------------------------------------------------------
14 #ifndef ZenLib_ZtringListListH
15 #define ZenLib_ZtringListListH
16 //---------------------------------------------------------------------------
17
18 //---------------------------------------------------------------------------
19 #include "ZenLib/ZtringList.h"
20 //---------------------------------------------------------------------------
21
22 namespace ZenLib
23 {
24
25 //***************************************************************************
26 /// @brief Vector of vectors of strings manipulation (based on std::vector<std::vector<std::(w)string>>)
27 //***************************************************************************
28
29 class ZtringListList : public std::vector<ZtringList>
30 {
31 public :
32 //Constructors/Destructor
33 ZtringListList ();
34 ZtringListList (const ZtringListList &Source);
35 ZtringListList (const Ztring &Source);
36 ZtringListList (const Char *Source);
37 #ifdef _UNICODE
38 ZtringListList (const char *Source); //convert a UTF-8 string into Unicode
39 #endif
40
41 //Operateurs
42 bool operator == (const ZtringListList &Source) const;
43 bool operator != (const ZtringListList &Source) const;
44 ZtringListList &operator += (const ZtringListList &Source);
45 ZtringListList &operator = (const ZtringListList &Source);
46
47 ZtringList &operator () (size_type Pos0); ///< Same as [], but write a empty string if Pos doesn't exist yet
48 Ztring &operator () (size_type Pos0, size_type Pos1);
49 /// @brief Return [Pos][Pos1], Pos=First occurency of Pos0 in [xxx][0]
50 Ztring &operator () (const Ztring &Pos0, size_type Pos1=1) {return operator() (Pos0, 0 , Pos1);}
51 /// @brief Return [Pos][Pos1], Pos=First occurency of Pos0 in [xxx][Pos0_1]
52 Ztring &operator () (const Ztring &Pos0, size_type Pos0_1, size_type Pos1);
53
54 //In/Out
55 /// @brief Read all
56 Ztring Read () const;
57 /// @brief Read a vector of string
58 Ztring Read (size_type Pos0) const;
59 /// @brief Read a string
60 const Ztring &Read (size_type Pos0, size_type Pos1) const;
61 /// @brief Return [Pos][Pos1], Pos=First occurency of Pos0 in [xxx][0]
62 const Ztring &Read (const Ztring &Pos0, size_type Pos1=1) const;
63 /// @brief Return [Pos][Pos1], Pos=First occurency of Pos0 in [xxx][Pos0_1]
64 const Ztring &Read (const Ztring &Pos0, size_type Pos0_1, size_type Pos1) const;
65 /// @brief Return [Pos][Pos1], Pos=First occurency of Pos0 in [xxx][0], with default value
66 const Ztring &Read (const Ztring &Pos0, const Ztring &Default, size_type Pos1=1) const;
67 /// @brief Return [Pos][Pos1], Pos=First occurency of Pos0 in [xxx][Pos0_1], with default value
68 const Ztring &Read (const Ztring &Pos0, const Ztring &Default, size_type Pos0_1, size_type Pos1) const;
69 /// @brief Read all strings at position Pos1
70 Ztring Read1 (size_type Pos1) const;
71
72 /// @brief Write all
73 void Write (const Ztring &ToWrite);
74 /// @brief Write a vector of string
75 void Write (const ZtringList &ToWrite, size_type Pos0);
76 /// @brief Write a vector of string
77 void Write (const Ztring &ToWrite, size_type Pos0, size_type Pos1);
78 /// @brief Add a vector of string
79 void push_back (const ZtringList &ToAdd);
80 /// @brief Add a vector of string (with separator is ZtringListList Separator)
81 void push_back (const Ztring &ToAdd);
82 /// @brief Add a vector of string (Char version)
83 void push_back (const Char* ToAdd) {push_back(Ztring(ToAdd));}
84 /// @brief Insert a vector of string at position Pos0
85 void Insert (const ZtringList &ToInsert, size_type Pos0) {insert(begin()+Pos0, ToInsert);}
86 /// @brief Insert a string at all positions Pos1
87 void Insert1 (const Ztring &ToInsert, size_type Pos1);
88 /// @brief Delete a vector of string at position Pos0
89 void Delete (size_type Pos0) {erase(begin()+Pos0);}
90 /// @brief Delete all vectors of string, with [xxx][Pos1] == ToFind
91 void Delete (const Ztring &ToFind, size_type Pos1=0, const Ztring &Comparator=__T("=="), ztring_t Options=Ztring_Nothing);
92 /// @brief Delete a string at all positions Pos1
93 void Delete1 (size_type Pos1);
94
95 //Edition
96 /// @brief Swap 2 positions
97 void Swap (size_type Pos0_A, size_type Pos0_B);
98 /// @brief Swap 2 columns for each line
99 void Swap1 (size_type Pos1_A, size_type Pos1_B);
100 /// @brief Sort
101 void Sort (size_type Pos1, ztring_t Options=Ztring_Nothing);
102
103 //Information
104 /// @brief Find the first position of the string in the vector of vector, in a specific column
105 size_type Find (const Ztring &ToFind, size_type Pos1=0, size_type Pos0Begin=0) const;
106 /// @brief Find the first position of the string in the vector of vector, in a specific column, which is not empty
107 size_type Find_Filled (size_type Pos1=0, size_type Pos0Begin=0) const;
108 /// @brief Find the first position of the string in the vector of vector, in a specific column
109 size_type Find (const Ztring &ToFind, size_type Pos1, size_type Pos0Begin, const Ztring &Comparator, ztring_t Options=Ztring_Nothing) const;
110 /// @brief Return [xxx][Pos1Value] when founded the first position of the string in the vector of vector, in a specific column
111 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;
112 /// @brief Return a subsheet, with all lines with position of the string in the vector of vector, in a specific column
113 ZtringListList SubSheet (const Ztring &ToFind, size_type Pos1=0, size_type Pos0Begin=0, const Ztring &Comparator=__T("=="), ztring_t Options=Ztring_Nothing) const;
114
115 //Configuration
116 /// @brief Set the Separator character
117 void Separator_Set (size_type Level, const Ztring &NewSeparator);
118 /// @brief Set the Quote character
119 /// During Read() or Write() method, if Separator is in the sequence, we must quote it
120 void Quote_Set (const Ztring &NewQuote);
121 /// @brief Set the Maximum number of element to read
122 /// During Read() or Write() method, if there is more elements, merge them with the last element
123 void Max_Set (size_type Level, size_type Max);
124
125 protected :
126 Ztring Separator[2];
127 Ztring Quote;
128 size_type Max[2];
129 };
130
131 } //namespace
132 #endif
ZenLib::ZtringListList::operator=
ZtringListList & operator=(const ZtringListList &Source)
ZenLib::ZtringListList::operator+=
ZtringListList & operator+=(const ZtringListList &Source)
ZenLib::ZtringListList::Read
Ztring Read() const
Read all.
ZenLib::ZtringListList::Separator
Ztring Separator[2]
Definition: ZtringListList.h:126
ZenLib::Char
char Char
Definition: Conf.h:215
ZenLib::Ztring_Nothing
Definition: Ztring.h:35
ZenLib::ZtringListList::Delete1
void Delete1(size_type Pos1)
Delete a string at all positions Pos1.
ZenLib::ZtringListList::operator()
ZtringList & operator()(size_type Pos0)
Same as [], but write a empty string if Pos doesn't exist yet.
ZenLib::ZtringListList::Insert
void Insert(const ZtringList &ToInsert, size_type Pos0)
Insert a vector of string at position Pos0.
Definition: ZtringListList.h:85
ZenLib::ZtringListList::Max_Set
void Max_Set(size_type Level, size_type Max)
Set the Maximum number of element to read During Read() or Write() method, if there is more elements...
ZenLib
Definition: BitStream.h:23
ZenLib::ZtringList
Vector of strings manipulation (based on std::vector)
Definition: ZtringList.h:30
ZenLib::ZtringListList::operator==
bool operator==(const ZtringListList &Source) const
ZenLib::ztring_t
ztring_t
Options for Ztring methods.
Definition: Ztring.h:33
ZtringList.h
ZenLib::ZtringListList::Sort
void Sort(size_type Pos1, ztring_t Options=Ztring_Nothing)
Sort.
ZenLib::ZtringListList::Separator_Set
void Separator_Set(size_type Level, const Ztring &NewSeparator)
Set the Separator character.
ZenLib::ZtringListList::ZtringListList
ZtringListList()
ZenLib::ZtringListList
Vector of vectors of strings manipulation (based on std::vector>) ...
Definition: ZtringListList.h:29
ZenLib::Ztring
String manipulation (based on std::(w)string)
Definition: Ztring.h:49
ZenLib::ZtringListList::Swap1
void Swap1(size_type Pos1_A, size_type Pos1_B)
Swap 2 columns for each line.
__T
#define __T(__x)
Definition: Conf.h:217
ZenLib::ZtringListList::Quote
Ztring Quote
Definition: ZtringListList.h:127
ZenLib::ZtringListList::Write
void Write(const Ztring &ToWrite)
Write all.
ZenLib::ZtringListList::Quote_Set
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.
ZenLib::ZtringListList::FindValue
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
Return [xxx][Pos1Value] when founded the first position of the string in the vector of vector...
ZenLib::ZtringListList::push_back
void push_back(const ZtringList &ToAdd)
Add a vector of string.
ZenLib::ZtringListList::operator!=
bool operator!=(const ZtringListList &Source) const
ZenLib::ZtringListList::Max
size_type Max[2]
Definition: ZtringListList.h:128
ZenLib::ZtringListList::push_back
void push_back(const Char *ToAdd)
Add a vector of string (Char version)
Definition: ZtringListList.h:83
ZenLib::ZtringListList::Delete
void Delete(size_type Pos0)
Delete a vector of string at position Pos0.
Definition: ZtringListList.h:89
ZenLib::ZtringListList::Read1
Ztring Read1(size_type Pos1) const
Read all strings at position Pos1.
ZenLib::ZtringListList::Swap
void Swap(size_type Pos0_A, size_type Pos0_B)
Swap 2 positions.
ZenLib::ZtringListList::Find_Filled
size_type Find_Filled(size_type Pos1=0, size_type Pos0Begin=0) const
Find the first position of the string in the vector of vector, in a specific column, which is not empty.
ZenLib::ZtringListList::SubSheet
ZtringListList SubSheet(const Ztring &ToFind, size_type Pos1=0, size_type Pos0Begin=0, const Ztring &Comparator=__T("=="), ztring_t Options=Ztring_Nothing) const
Return a subsheet, with all lines with position of the string in the vector of vector, in a specific column.
ZenLib::ZtringListList::Find
size_type Find(const Ztring &ToFind, size_type Pos1=0, size_type Pos0Begin=0) const
Find the first position of the string in the vector of vector, in a specific column.
ZenLib::ZtringListList::Insert1
void Insert1(const Ztring &ToInsert, size_type Pos1)
Insert a string at all positions Pos1.