RVNGString.h Source File documentation

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#include <string>
26
27namespace librevenge
28{
29
30class RVNGStringImpl;
31
34 class REVENGE_API RVNGString
35{
36public:
37 RVNGString();
38 RVNGString(const RVNGString &other);
39 RVNGString(const char *str);
40 RVNGString(std::string&&);
41 ~RVNGString();
42
50 static RVNGString escapeXML(const RVNGString &s);
51
59 static RVNGString escapeXML(const char *s);
60
61 const char *cstr() const;
62
67 int len() const;
74 unsigned long size() const;
75
76 bool empty() const;
77
78 void sprintf(const char *format, ...) REVENGE_ATTRIBUTE_PRINTF(2, 3);
79 void append(const RVNGString &s);
80 void append(const char *s);
81 void append(const char c);
82
87 void appendEscapedXML(const RVNGString &s);
88
93 void appendEscapedXML(const char *s);
94
95 void clear();
96 RVNGString &operator=(const RVNGString &str);
97 RVNGString &operator=(const char *s);
98
99 // Comparison
100 bool operator==(const char *s) const;
101 bool operator==(const RVNGString &str) const;
102 inline bool operator!=(const char *s) const
103 {
104 return !operator==(s);
105 }
106 inline bool operator!=(const RVNGString &str) const
107 {
108 return !operator==(str);
109 }
110 bool operator<(const char *s) const;
111 bool operator<(const RVNGString &str) const;
112 inline bool operator<=(const char *s) const
113 {
114 return operator==(s) || operator<(s);
115 }
116 inline bool operator<=(const RVNGString &str) const
117 {
118 return operator==(str) || operator<(str);
119 }
120 inline bool operator>=(const char *s) const
121 {
122 return !operator<(s);
123 }
124 inline bool operator>=(const RVNGString &str) const
125 {
126 return !operator<(str);
127 }
128 inline bool operator>(const char *s) const
129 {
130 return !operator<=(s);
131 }
132 inline bool operator>(const RVNGString &str) const
133 {
134 return !operator<=(str);
135 }
136
137 class REVENGE_API Iter
138 {
139 public:
140 Iter(const RVNGString &str);
141 virtual ~Iter();
142 void rewind();
143 bool next();
144 bool last();
145 const char *operator()() const;
146 private:
147 Iter(const Iter &);
148 Iter &operator=(const Iter &);
149 RVNGStringImpl *m_stringImpl;
150 int m_pos;
151 mutable char *m_curChar;
152 };
153
154private:
155 RVNGStringImpl *m_stringImpl;
156};
157
158}
159
160#endif
161/* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */
librevenge::RVNGStringImpl
Definition RVNGString.cpp:76
librevenge::RVNGString::Iter::next
bool next()
Definition RVNGString.cpp:361
librevenge::RVNGString::Iter::rewind
void rewind()
Definition RVNGString.cpp:356
librevenge::RVNGString::Iter::m_pos
int m_pos
Definition RVNGString.h:150
librevenge::RVNGString::Iter::operator=
Iter & operator=(const Iter &)
librevenge::RVNGString::Iter::operator()
const char * operator()() const
Definition RVNGString.cpp:386
librevenge::RVNGString::Iter::m_curChar
char * m_curChar
Definition RVNGString.h:151
librevenge::RVNGString::Iter::m_stringImpl
RVNGStringImpl * m_stringImpl
Definition RVNGString.h:149
librevenge::RVNGString::Iter::Iter
Iter(const Iter &)
librevenge::RVNGString::Iter::Iter
Iter(const RVNGString &str)
Definition RVNGString.cpp:342
librevenge::RVNGString::Iter::last
bool last()
Definition RVNGString.cpp:378
librevenge::RVNGString
UTF-8 string.
Definition RVNGString.h:35
librevenge::RVNGString::size
unsigned long size() const
Return the size in bytes of the data buffer.
Definition RVNGString.cpp:294
librevenge::RVNGString::clear
void clear()
Definition RVNGString.cpp:284
librevenge::RVNGString::empty
bool empty() const
Definition RVNGString.cpp:299
librevenge::RVNGString::operator!=
bool operator!=(const RVNGString &str) const
Definition RVNGString.h:106
librevenge::RVNGString::operator<=
bool operator<=(const RVNGString &str) const
Definition RVNGString.h:116
librevenge::RVNGString::operator!=
bool operator!=(const char *s) const
Definition RVNGString.h:102
librevenge::RVNGString::escapeXML
static RVNGString escapeXML(const RVNGString &s)
Create a new string from s as escaped XML.
Definition RVNGString.cpp:209
librevenge::RVNGString::operator>=
bool operator>=(const RVNGString &str) const
Definition RVNGString.h:124
librevenge::RVNGString::operator>
bool operator>(const char *s) const
Definition RVNGString.h:128
librevenge::RVNGString::cstr
const char * cstr() const
Definition RVNGString.cpp:223
librevenge::RVNGString::operator>=
bool operator>=(const char *s) const
Definition RVNGString.h:120
librevenge::RVNGString::sprintf
void sprintf(const char *format,...) REVENGE_ATTRIBUTE_PRINTF(2
Definition RVNGString.cpp:228
librevenge::RVNGString::operator==
bool operator==(const char *s) const
Definition RVNGString.cpp:318
librevenge::RVNGString::append
void void append(const RVNGString &s)
Definition RVNGString.cpp:258
librevenge::RVNGString::operator<
bool operator<(const char *s) const
Definition RVNGString.cpp:330
librevenge::RVNGString::len
int len() const
Return the number of UTF-8 characters.
Definition RVNGString.cpp:289
librevenge::RVNGString::operator>
bool operator>(const RVNGString &str) const
Definition RVNGString.h:132
librevenge::RVNGString::operator=
RVNGString & operator=(const RVNGString &str)
Definition RVNGString.cpp:304
librevenge::RVNGString::appendEscapedXML
void appendEscapedXML(const RVNGString &s)
Append the content of s as escaped XML.
Definition RVNGString.cpp:274
librevenge::RVNGString::RVNGString
RVNGString()
Definition RVNGString.cpp:185
librevenge::RVNGString::m_stringImpl
RVNGStringImpl * m_stringImpl
Definition RVNGString.h:155
librevenge::RVNGString::operator<=
bool operator<=(const char *s) const
Definition RVNGString.h:112
librevenge-api.h
REVENGE_API
#define REVENGE_API
Definition librevenge-api.h:34
REVENGE_ATTRIBUTE_PRINTF
#define REVENGE_ATTRIBUTE_PRINTF(fmt, arg)
Definition librevenge-api.h:41
librevenge
Definition RVNGBinaryData.cpp:40