Added debugger documentation to reference guide and user guide
[deliverable/titan.core.git] / xsdconvert / Mstring.hh
CommitLineData
d44e3c4f 1/******************************************************************************
2 * Copyright (c) 2000-2016 Ericsson Telecom AB
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * Balasko, Jeno
10 * Godar, Marton
11 * Raduly, Csaba
12 * Szabo, Bence Janos
13 *
14 ******************************************************************************/
970ed795
EL
15#ifndef XSTRING_HH_
16#define XSTRING_HH_
17
18#include "../common/memory.h"
19
3abe9331 20class Mstring {
970ed795
EL
21 expstring_t text;
22
23public:
24 /**
25 * Construct Mstring object
26 */
27
28 /**
29 * Content is initialized to an empty (non-NULL) Mstring via memptystr()
30 */
31 Mstring();
32
33 /**
34 * Content is initialized to a copy of the Mstring object str.
35 */
36 Mstring(const Mstring & str);
37
38 /**
39 * Content is initialized to a copy of the string
40 * formed by the null-terminated character sequence (C string) pointed by s.
41 * The length of the character sequence is determined by the first occurrence of a null character.
42 * If s is NULL, content is initialized to an empty Mstring
43 */
44 explicit Mstring(const char * s);
45
46 /**
47 * Content is initialized to a single character c.
48 */
49 explicit Mstring(char c);
50
51 /** Construct from \a len characters at \a s (may not be null-terminated) */
52 Mstring(size_t len, const char *s);
53
54 /**
55 * Destruct Mstring object
56 */
57 ~Mstring();
58
59 /**
60 * Test if Mstring is empty
61 * true if the Mstring size is 0
62 * false otherwise
63 */
64 bool empty() const;
65
66 /**
67 * Return length of Mstring
68 */
69 size_t size() const;
70
71 /**
72 * The Mstring content is set to an empty Mstring,
73 * erasing any previous content and thus leaving its size at 0 characters.
74 */
75 void clear();
76
77 /**
78 * Generates a null-terminated sequence of characters (c-string)
79 * with the same content as the Mstring object and
80 * returns it as a pointer to an array of characters.
81 */
82 const char * c_str() const;
83
84 /**
85 * The function deletes one character at position pos from the Mstring content
86 * Size is reduced by one
87 */
88 void eraseChar(size_t pos);
89
90 /**
91 * The function inserts one character before position into the Mstring content
92 * Size is increments by one
93 */
94 void insertChar(size_t pos, char c);
95
96 /**
97 * Look for s Mstring content
98 * true if s is found
99 * false otherwise
100 */
101 bool isFound(const Mstring & s);
102
103 /**
104 * Look for s c-string content
105 * true if s is found
106 * false otherwise
107 */
108 bool isFound(const char * s);
109
110 /**
111 * Look for c character content
112 * true if s is found
113 * false otherwise
114 */
115 bool isFound(char c);
116
3abe9331 117 /**
118 * Look for c-string content
119 * and returns a pointer to the first
120 * character where the matching found,
121 * returns null otherwise
122 */
123 char * foundAt(const char * c);
124
970ed795
EL
125 /**
126 * The first character of the Mstring is set to uppercase
127 */
128 void setCapitalized();
129
130 /**
131 * The first character of the Mstring is set to lowercase
132 */
133 void setUncapitalized();
134
135 /**
136 * Creates a new Mstring object
137 * Looks for the first occurence of the give character (delimiter)
138 * If delimiter is found: * the prefix is found in the string *
139 * the content of the new object will be the part before the found char
140 * If delimiter is not found: * the prefix is not found in the string *
141 * the new object will be an empty Mstring
142 */
143 Mstring getPrefix(const char delimiter) const;
144
145 /**
146 * Creates a new Mstring object
147 * Looks for the last occurence of the give character (delimiter)
148 * If delimiter is found: * the prefix is found in the string *
149 * the content of the new object will be the part after the found char
150 * If delimiter is not found: * the prefix is not found in the string *
151 * the new object will be the copy of this Mstring
152 */
153 Mstring getValueWithoutPrefix(const char delimiter) const;
154
155 /**
156 * Remove all whitespace characters (' ', '\n', '\t', '\r')
157 * from the begining or the end of the Mstring content
158 */
159 void removeWSfromBegin();
160 void removeWSfromEnd();
161
162 /**
163 * Get character in string
164 * Returns a reference the character at position pos in the string.
165 */
3abe9331 166 char & operator[](size_t pos);
167 const char & operator[](size_t pos) const;
970ed795
EL
168
169 /**
170 * Mstring assignment
171 * Sets a copy of the argument as the new content for the string object.
172 * The previous content is dropped.
173 */
3abe9331 174 Mstring & operator=(const Mstring & str);
175 Mstring & operator=(const char * s);
176 Mstring & operator=(char c);
177
178 const Mstring * operator*() const {
179 return this;
180 }
970ed795
EL
181
182 /**
183 * Append to Mstring
184 * Appends a copy of the argument to the Mstring content.
185 * The new Mstring content is the content existing in the string object before the call
186 * followed by the content of the argument.
187 */
3abe9331 188 Mstring & operator+=(const Mstring & str);
189 Mstring & operator+=(const char * s);
190 Mstring & operator+=(char c);
970ed795
EL
191
192 /**
193 * String comparison operators
194 * These overloaded global operator functions perform the appropriate comparison operation between lhs and rhs.
195 *
196 */
3abe9331 197 friend bool operator==(const Mstring & lhs, const Mstring & rhs);
198 friend bool operator==(const char * lhs, const Mstring & rhs);
199 friend bool operator==(const Mstring & lhs, const char * rhs);
970ed795 200
3abe9331 201 friend bool operator!=(const Mstring & lhs, const Mstring & rhs);
202 friend bool operator!=(const char * lhs, const Mstring & rhs);
203 friend bool operator!=(const Mstring & lhs, const char * rhs);
970ed795 204
3abe9331 205 friend bool operator<(const Mstring & lhs, const Mstring & rhs);
206 friend bool operator<(const char * lhs, const Mstring & rhs);
207 friend bool operator<(const Mstring & lhs, const char * rhs);
970ed795 208
3abe9331 209 friend bool operator>(const Mstring & lhs, const Mstring & rhs);
210 friend bool operator>(const char * lhs, const Mstring & rhs);
211 friend bool operator>(const Mstring & lhs, const char * rhs);
970ed795 212
3abe9331 213 friend bool operator<=(const Mstring & lhs, const Mstring & rhs);
214 friend bool operator<=(const char * lhs, const Mstring & rhs);
215 friend bool operator<=(const Mstring & lhs, const char * rhs);
970ed795 216
3abe9331 217 friend bool operator>=(const Mstring & lhs, const Mstring & rhs);
218 friend bool operator>=(const char * lhs, const Mstring & rhs);
219 friend bool operator>=(const Mstring & lhs, const char * rhs);
970ed795
EL
220};
221
222/*
223 * Add strings
224 * Returns an Mstring object whose contents are the combination of the content of lhs followed by those of rhs.
225 */
3abe9331 226const Mstring operator+(const Mstring & lhs, const Mstring & rhs);
227const Mstring operator+(const char * lhs, const Mstring & rhs);
228const Mstring operator+(char lhs, const Mstring & rhs);
229const Mstring operator+(const Mstring & lhs, const char * rhs);
230const Mstring operator+(const Mstring & lhs, char rhs);
231
232bool operator==(const Mstring & lhs, const Mstring & rhs);
233bool operator==(const char * lhs, const Mstring & rhs);
234bool operator==(const Mstring & lhs, const char * rhs);
235
236bool operator!=(const Mstring & lhs, const Mstring & rhs);
237bool operator!=(const char * lhs, const Mstring & rhs);
238bool operator!=(const Mstring & lhs, const char * rhs);
239
240bool operator<(const Mstring & lhs, const Mstring & rhs);
241bool operator<(const char * lhs, const Mstring & rhs);
242bool operator<(const Mstring & lhs, const char * rhs);
243
244bool operator>(const Mstring & lhs, const Mstring & rhs);
245bool operator>(const char * lhs, const Mstring & rhs);
246bool operator>(const Mstring & lhs, const char * rhs);
247
248bool operator<=(const Mstring & lhs, const Mstring & rhs);
249bool operator<=(const char * lhs, const Mstring & rhs);
250bool operator<=(const Mstring & lhs, const char * rhs);
251
252bool operator>=(const Mstring & lhs, const Mstring & rhs);
253bool operator>=(const char * lhs, const Mstring & rhs);
254bool operator>=(const Mstring & lhs, const char * rhs);
970ed795
EL
255
256extern const Mstring empty_string;
257
258#endif /* XSTRING_HH_ */
This page took 0.034583 seconds and 5 git commands to generate.