RVNGString.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2 /* librevenge
3 * Version: MPL 2.0 / LGPLv2.1+
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * Major Contributor(s):
10 * Copyright (C) 2004 William Lachance (wrlach@gmail.com)
11 * Copyright (C) 2006 Fridrich Strba (fridrich.strba@bluewin.ch)
12 *
13 * For minor contributions see the git repository.
14 *
15 * Alternatively, the contents of this file may be used under the terms
16 * of the GNU Lesser General Public License Version 2.1 or later
17 * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
18 * applicable instead of those above.
19 */
20
21 #ifndef RVNGSTRING_H
22 #define RVNGSTRING_H
23
24 #include "librevenge-api.h"
25
26 namespace librevenge
27 {
28
29 class RVNGStringImpl;
30
33 class REVENGE_API RVNGString
34 {
35 public:
36 RVNGString();
37 RVNGString(const RVNGString &other);
38 RVNGString(const char *str);
39 ~RVNGString();
40
48 static RVNGString escapeXML(const RVNGString &s);
49
57 static RVNGString escapeXML(const char *s);
58
59 const char *cstr() const;
60
65 int len() const;
72 unsigned long size() const;
73
74 bool empty() const;
75
76 void sprintf(const char *format, ...) REVENGE_ATTRIBUTE_PRINTF(2, 3);
77 void append(const RVNGString &s);
78 void append(const char *s);
79 void append(const char c);
80
85 void appendEscapedXML(const RVNGString &s);
86
91 void appendEscapedXML(const char *s);
92
93 void clear();
94 RVNGString &operator=(const RVNGString &str);
95 RVNGString &operator=(const char *s);
96
97 // Comparison
98 bool operator==(const char *s) const;
99 bool operator==(const RVNGString &str) const;
100 inline bool operator!=(const char *s) const
101 {
102 return !operator==(s);
103 }
104 inline bool operator!=(const RVNGString &str) const
105 {
106 return !operator==(str);
107 }
108 bool operator<(const char *s) const;
109 bool operator<(const RVNGString &str) const;
110 inline bool operator<=(const char *s) const
111 {
112 return operator==(s) || operator<(s);
113 }
114 inline bool operator<=(const RVNGString &str) const
115 {
116 return operator==(str) || operator<(str);
117 }
118 inline bool operator>=(const char *s) const
119 {
120 return !operator<(s);
121 }
122 inline bool operator>=(const RVNGString &str) const
123 {
124 return !operator<(str);
125 }
126 inline bool operator>(const char *s) const
127 {
128 return !operator<=(s);
129 }
130 inline bool operator>(const RVNGString &str) const
131 {
132 return !operator<=(str);
133 }
134
135 class REVENGE_API Iter
136 {
137 public:
138 Iter(const RVNGString &str);
139 virtual ~Iter();
140 void rewind();
141 bool next();
142 bool last();
143 const char *operator()() const;
144 private:
145 Iter(const Iter &);
146 Iter &operator=(const Iter &);
147 RVNGStringImpl *m_stringImpl;
148 int m_pos;
149 mutable char *m_curChar;
150 };
151
152 private:
153 RVNGStringImpl *m_stringImpl;
154 };
155
156 }
157
158 #endif
159 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */
librevenge::RVNGString::Iter::m_curChar
char * m_curChar
Definition: RVNGString.h:149
librevenge::RVNGString::m_stringImpl
RVNGStringImpl * m_stringImpl
Definition: RVNGString.h:153
librevenge
Definition: RVNGBinaryData.cpp:38
REVENGE_ATTRIBUTE_PRINTF
#define REVENGE_ATTRIBUTE_PRINTF(fmt, arg)
Definition: librevenge-api.h:41
librevenge::RVNGString::operator!=
bool operator!=(const RVNGString &str) const
Definition: RVNGString.h:104
librevenge::RVNGString::operator<=
bool operator<=(const RVNGString &str) const
Definition: RVNGString.h:114
librevenge::RVNGString::operator>
bool operator>(const RVNGString &str) const
Definition: RVNGString.h:130
librevenge::RVNGString::operator>
bool operator>(const char *s) const
Definition: RVNGString.h:126
librevenge::RVNGString::Iter::m_stringImpl
RVNGStringImpl * m_stringImpl
Definition: RVNGString.h:147
librevenge::RVNGStringImpl
Definition: RVNGString.cpp:72
librevenge::RVNGString::Iter
Definition: RVNGString.h:135
REVENGE_API
#define REVENGE_API
Definition: librevenge-api.h:34
librevenge::RVNGString::Iter::m_pos
int m_pos
Definition: RVNGString.h:148
librevenge::RVNGString::operator<=
bool operator<=(const char *s) const
Definition: RVNGString.h:110
librevenge::RVNGString::operator>=
bool operator>=(const char *s) const
Definition: RVNGString.h:118
librevenge-api.h
librevenge::RVNGString::operator>=
bool operator>=(const RVNGString &str) const
Definition: RVNGString.h:122
librevenge::RVNGString::operator!=
bool operator!=(const char *s) const
Definition: RVNGString.h:100
librevenge::RVNGString
UTF-8 string.
Definition: RVNGString.h:33