ZenLib
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
22namespace ZenLib
23{
24
25//***************************************************************************
26/// @brief Vector of vectors of strings manipulation (based on std::vector<std::vector<std::(w)string>>)
27//***************************************************************************
28
29class ZtringListList : public std::vector<ZtringList>
30{
31public :
32 //Constructors/Destructor
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;
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
125protected :
128 size_type Max[2];
129};
130
131} //namespace
132#endif
#define __T(__x)
Definition: Conf.h:227
Vector of vectors of strings manipulation (based on std::vector<std::vector<std::(w)string>>)
Definition: ZtringListList.h:30
void Insert(const ZtringList &ToInsert, size_type Pos0)
Insert a vector of string at position Pos0.
Definition: ZtringListList.h:85
bool operator!=(const ZtringListList &Source) const
ZtringListList(const Char *Source)
void Quote_Set(const Ztring &NewQuote)
Set the Quote character During Read() or Write() method, if Separator is in the sequence,...
ZtringListList(const ZtringListList &Source)
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,...
void Delete(const Ztring &ToFind, size_type Pos1=0, const Ztring &Comparator=__T("=="), ztring_t Options=Ztring_Nothing)
Delete all vectors of string, with [xxx][Pos1] == ToFind.
const Ztring & Read(const Ztring &Pos0, size_type Pos0_1, size_type Pos1) const
Return [Pos][Pos1], Pos=First occurency of Pos0 in [xxx][Pos0_1].
ZtringListList & operator+=(const ZtringListList &Source)
const Ztring & Read(const Ztring &Pos0, size_type Pos1=1) const
Return [Pos][Pos1], Pos=First occurency of Pos0 in [xxx][0].
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,...
Ztring Read1(size_type Pos1) const
Read all strings at position Pos1.
void Delete1(size_type Pos1)
Delete a string at all positions Pos1.
const Ztring & Read(const Ztring &Pos0, const Ztring &Default, size_type Pos1=1) const
Return [Pos][Pos1], Pos=First occurency of Pos0 in [xxx][0], with default value.
bool operator==(const ZtringListList &Source) const
void Delete(size_type Pos0)
Delete a vector of string at position Pos0.
Definition: ZtringListList.h:89
ZtringList & operator()(size_type Pos0)
Same as [], but write a empty string if Pos doesn't exist yet.
void push_back(const Ztring &ToAdd)
Add a vector of string (with separator is ZtringListList Separator)
size_type Find(const Ztring &ToFind, size_type Pos1, size_type Pos0Begin, const Ztring &Comparator, ztring_t Options=Ztring_Nothing) const
Find the first position of the string in the vector of vector, in a specific column.
void push_back(const Char *ToAdd)
Add a vector of string (Char version)
Definition: ZtringListList.h:83
void Swap1(size_type Pos1_A, size_type Pos1_B)
Swap 2 columns for each line.
const Ztring & Read(const Ztring &Pos0, const Ztring &Default, size_type Pos0_1, size_type Pos1) const
Return [Pos][Pos1], Pos=First occurency of Pos0 in [xxx][Pos0_1], with default value.
void Write(const Ztring &ToWrite, size_type Pos0, size_type Pos1)
Write a vector of string.
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,...
void push_back(const ZtringList &ToAdd)
Add a vector of string.
size_type Max[2]
Definition: ZtringListList.h:128
Ztring Read(size_type Pos0) const
Read a vector of string.
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.
const Ztring & Read(size_type Pos0, size_type Pos1) const
Read a string.
void Sort(size_type Pos1, ztring_t Options=Ztring_Nothing)
Sort.
Ztring Quote
Definition: ZtringListList.h:127
Ztring Separator[2]
Definition: ZtringListList.h:126
void Insert1(const Ztring &ToInsert, size_type Pos1)
Insert a string at all positions Pos1.
void Swap(size_type Pos0_A, size_type Pos0_B)
Swap 2 positions.
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,...
ZtringListList(const Ztring &Source)
void Write(const ZtringList &ToWrite, size_type Pos0)
Write a vector of string.
Ztring Read() const
Read all.
ZtringListList & operator=(const ZtringListList &Source)
void Write(const Ztring &ToWrite)
Write all.
void Separator_Set(size_type Level, const Ztring &NewSeparator)
Set the Separator character.
Vector of strings manipulation (based on std::vector<std::(w)string>)
Definition: ZtringList.h:31
String manipulation (based on std::(w)string)
Definition: Ztring.h:50
Definition: BitStream.h:24
char Char
Definition: Conf.h:225
ztring_t
Options for Ztring methods.
Definition: Ztring.h:34
@ Ztring_Nothing
Definition: Ztring.h:35