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
23namespace ZenLib
24{
25
26//***************************************************************************
27/// @brief Vector of strings manipulation (based on std::vector<std::(w)string>)
28//***************************************************************************
29
30class ZtringList : public std::vector<Ztring>
31{
32public :
33 //Constructors/destructor
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;
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
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
82protected :
85 size_type Max[1];
86};
87
88} //namespace
89#endif
#define __T(__x)
Definition Conf.h:227
void Quote_Set(const Ztring &NewQuote)
Set the Quote character During Read() or Write() method, if Separator is in the sequence,...
void Delete(size_type Pos0)
Delete a string at position Pos0.
Definition ZtringList.h:58
Ztring Quote
Definition ZtringList.h:84
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.
bool operator!=(const ZtringList &Source) const
ZtringList(const Char *Source)
Ztring Separator[1]
Definition ZtringList.h:83
void Sort(ztring_t Options=Ztring_Nothing)
Sort.
void Write(const Ztring &ToWrite, size_type Pos)
Write all.
Ztring Read() const
void Swap(size_type Pos0_A, size_type Pos0_B)
Swap 2 positions.
size_type Max[1]
Definition ZtringList.h:85
bool operator==(const ZtringList &Source) const
size_type MaxStringLength_Get()
Return the length of the longest string in the list.
ZtringList(const ZtringList &Source)
ZtringList & operator+=(const ZtringList &Source)
void Insert(const Ztring &ToInsert, size_type Pos0)
Insert a string at position Pos0.
Definition ZtringList.h:56
Ztring & operator()(size_type Pos)
Same as [], but write a empty string if Pos doesn't exist yet.
void Write(const Ztring &ToWrite)
Read a string.
ZtringList & operator=(const ZtringList &Source)
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,...
void Separator_Set(size_type Level, const Ztring &NewSeparator)
Set the Separator character.
ZtringList(const Ztring &Source)
const Ztring & Read(size_type Pos) const
Read all.
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