ZenLib

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

- File List
- File Members

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 :
83 Ztring Separator[1];
84 Ztring Quote;
85 size_type Max[1];
86 };
87
88 } //namespace
89 #endif
ZenLib::Char
char Char
Definition: Conf.h:215
ZenLib::ZtringList::operator+=
ZtringList & operator+=(const ZtringList &Source)
ZenLib::Ztring_Nothing
Definition: Ztring.h:35
ZenLib::ZtringList::Separator_Set
void Separator_Set(size_type Level, const Ztring &NewSeparator)
Set the Separator character.
ZenLib::ZtringList::operator==
bool operator==(const ZtringList &Source) const
ZenLib::ZtringList::operator()
Ztring & operator()(size_type Pos)
Same as [], but write a empty string if Pos doesn't exist yet.
ZenLib
Definition: BitStream.h:23
ZenLib::ZtringList::operator!=
bool operator!=(const ZtringList &Source) const
ZenLib::ZtringList::Max_Set
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...
ZenLib::ZtringList::Read
Ztring Read() const
ZenLib::ZtringList::Delete
void Delete(size_type Pos0)
Delete a string at position Pos0.
Definition: ZtringList.h:58
ZenLib::ZtringList
Vector of strings manipulation (based on std::vector)
Definition: ZtringList.h:30
ZenLib::ZtringList::Separator
Ztring Separator[1]
Definition: ZtringList.h:83
ZenLib::ZtringList::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::ztring_t
ztring_t
Options for Ztring methods.
Definition: Ztring.h:33
ZenLib::ZtringList::Swap
void Swap(size_type Pos0_A, size_type Pos0_B)
Swap 2 positions.
ZenLib::ZtringList::Find
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.
ZenLib::ZtringList::Write
void Write(const Ztring &ToWrite)
Read a string.
ZenLib::ZtringList::Sort
void Sort(ztring_t Options=Ztring_Nothing)
Sort.
ZenLib::Ztring
String manipulation (based on std::(w)string)
Definition: Ztring.h:49
__T
#define __T(__x)
Definition: Conf.h:217
ZenLib::ZtringList::operator=
ZtringList & operator=(const ZtringList &Source)
ZenLib::ZtringList::ZtringList
ZtringList()
ZenLib::ZtringList::Insert
void Insert(const Ztring &ToInsert, size_type Pos0)
Insert a string at position Pos0.
Definition: ZtringList.h:56
ZenLib::ZtringList::MaxStringLength_Get
size_type MaxStringLength_Get()
Return the length of the longest string in the list.
ZenLib::ZtringList::Quote
Ztring Quote
Definition: ZtringList.h:84
Ztring.h
ZenLib::ZtringList::Max
size_type Max[1]
Definition: ZtringList.h:85