MezzanineEngine
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
Mezzanine
src
XML
nodetext.h
Go to the documentation of this file.
1
// © Copyright 2010 - 2014 BlackTopp Studios Inc.
2
/* This file is part of The Mezzanine Engine.
3
4
The Mezzanine Engine is free software: you can redistribute it and/or modify
5
it under the terms of the GNU General Public License as published by
6
the Free Software Foundation, either version 3 of the License, or
7
(at your option) any later version.
8
9
The Mezzanine Engine is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
13
14
You should have received a copy of the GNU General Public License
15
along with The Mezzanine Engine. If not, see <http://www.gnu.org/licenses/>.
16
*/
17
/* The original authors have included a copy of the license specified above in the
18
'Docs' folder. See 'gpl.txt'
19
*/
20
/* We welcome the use of the Mezzanine engine to anyone, including companies who wish to
21
Build professional software and charge for their product.
22
23
However there are some practical restrictions, so if your project involves
24
any of the following you should contact us and we will try to work something
25
out:
26
- DRM or Copy Protection of any kind(except Copyrights)
27
- Software Patents You Do Not Wish to Freely License
28
- Any Kind of Linking to Non-GPL licensed Works
29
- Are Currently In Violation of Another Copyright Holder's GPL License
30
- If You want to change our code and not add a few hundred MB of stuff to
31
your distribution
32
33
These and other limitations could cause serious legal problems if you ignore
34
them, so it is best to simply contact us or the Free Software Foundation, if
35
you have any questions.
36
37
Joseph Toppi - toppij@gmail.com
38
John Blackwood - makoenergy02@gmail.com
39
*/
40
/*
41
*
42
* Software, Files, Libraries and all other items referenced in this clause refers only
43
* to the contents of this file and associated documentation.
44
*
45
* Pugixml parser - version 1.0
46
* --------------------------------------------------------
47
* Copyright © 2006-2012, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
48
* Report bugs and download new versions at http://pugixml.org/
49
*
50
* This library is distributed under the MIT License. See notice at the end
51
* of this file.
52
*
53
* This work is based on the pugxml parser, which is:
54
* Copyright © 2003, by Kristen Wegner (kristen@tima.net)
55
*/
56
#ifndef _xmlnodetext_h
57
#define _xmlnodetext_h
58
59
/// @file
60
/// @brief The declaration of the XML::NodeText class
61
62
#include "
datatypes.h
"
63
#include "
node.h
"
64
#include "
swig.h
"
65
66
67
68
namespace
Mezzanine
69
{
70
namespace
XML
71
{
72
/// @brief A helper for working with text inside PCDATA nodes.
73
class
MEZZ_LIB
NodeText
74
{
75
friend
class
Node
;
76
77
/// @brief Actually the the data for this NodeText
78
NodeStruct* RootNode;
79
80
#ifndef SWIG
81
/// @brief Used to prevent casting to numerical types acccidentally.
82
/// @note Not available in scripting languages because conversion is handled on a per langauge basis
83
typedef
void (*unspecified_bool_type)(
NodeText
***);
84
#endif
85
86
/// @internal
87
/// @brief Create this from the internal data of another node.
88
explicit
NodeText
(NodeStruct* OtherRoot);
89
90
/// @internal
91
/// @brief Get the internal data pointer for the nearest Parent node or allocate one if required.
92
NodeStruct* DataNew();
93
94
/// @internal
95
/// @brief Get the internal data pointer for the nearest Parent node
96
NodeStruct* Data()
const
;
97
98
public
:
99
/// @brief Default constructor. Constructs an empty object.
100
NodeText();
101
102
#ifndef SWIG
103
/// @brief Used to convert this to a boolean value in a safe way
104
/// @return Returns true if the internal data is set and false otherwise.
105
operator
unspecified_bool_type()
const
;
106
#endif
107
108
/// @brief Used to convert this attribute the opposite of it's normal boolean value
109
/// @details This is described in the PugiXML source a a workaround for a borland c++ issue.
110
/// @return Returns false if the internal pointer AttributeStruct is set and true otherwise.
111
bool
operator!()
const
;
112
113
/// @brief Is this storing anything at all?
114
/// @return Returns True if this @ref NodeText is storing nothing. False if it is storing anything.
115
bool
Empty()
const
;
116
117
/// @brief Get text, or "" if object is empty
118
/// @return A pointer to the string or "" if this is empty.
119
const
Char8
* GetString()
const
;
120
121
/// @brief Get text, or the default Value if object is empty
122
/// @param def The value to be returned if there is no valid return
123
/// @return This will return The content of this node or def
124
const
Char8
* AsString(
const
Char8
* def =
""
)
const
;
125
126
/// @brief Get text as a number, or the default Value if conversion did not succeed or object is empty
127
/// @param def The value To be returned if an error occurs in conversion, like a an out of memory condition.
128
/// @return The value in this @ref NodeText as an int or def if the text is invalid for conversion or generates an error.
129
int
AsInt(
int
def = 0)
const
;
130
131
/// @brief Get text as a number, or the default Value if conversion did not succeed or object is empty
132
/// @param def The value To be returned if an error occurs in conversion, like a an out of memory condition.
133
/// @return The value in this @ref NodeText as an unisgned int or def if the text is invalid for conversion or generates an error.
134
unsigned
int
AsUint(
unsigned
int
def = 0)
const
;
135
136
/// @brief Get text as a number, or the default Value if conversion did not succeed or object is empty
137
/// @param def The value To be returned if an error occurs in conversion, like a an out of memory condition.
138
/// @return The value in this @ref NodeText as a double or def if the text is invalid for conversion or generates an error.
139
double
AsDouble(
double
def = 0)
const
;
140
141
/// @brief Get text as a number, or the default Value if conversion did not succeed or object is empty
142
/// @param def The value To be returned if an error occurs in conversion, like a an out of memory condition.
143
/// @return The value in this @ref NodeText as a float or def if the text is invalid for conversion or generates an error.
144
float
AsFloat(
float
def = 0)
const
;
145
146
/// @brief Get text as a number, or the default Value if conversion did not succeed or object is empty
147
/// @param def The value To be returned if an error occurs in conversion, like a an out of memory condition.
148
/// @return The value in this @ref NodeText as a Mezzanine::Real or def if the text is invalid for conversion or generates an error.
149
Real
AsReal(
Real
def = 0)
const
;
150
151
/// @brief Get text as a number, or the default Value if conversion did not succeed or object is empty
152
/// @param def The value To be returned if an error occurs in conversion, like a an out of memory condition.
153
/// @return The value in this @ref NodeText as a Mezzanine::Whole or def if the text is invalid for conversion or generates an error.
154
Whole
AsWhole(
Whole
def = 0)
const
;
155
156
/// @brief Get text as a number, or the default Value if conversion did not succeed or object is empty
157
/// @param def The value To be returned if an error occurs in conversion, like a an out of memory condition.
158
/// @return The value in this @ref NodeText as a Mezzanine::Integer or def if the text is invalid for conversion or generates an error.
159
Integer
AsInteger(
Integer
def = 0)
const
;
160
161
/// @brief Get text as bool
162
/// @param def The default value to return if conversion is not possible.
163
/// @return True if first character is in '1tTyY' set), or the default Value if object is empty.
164
bool
AsBool(
bool
def =
false
)
const
;
165
166
/// @brief Set text
167
/// @param rhs The value to store in this text.
168
/// @return False if object is empty or there is not enough memory.
169
bool
Set(
const
Char8
* rhs);
170
171
#if !(defined(SWIG) && defined(MEZZLUA51)) // Stop Swig from making lua bindings but allow other languages
172
/// @brief Set text by lexigraphically converting rhs.
173
/// @param rhs The value to store in this text.
174
/// @return False if object is empty or there is not enough memory.
175
bool
Set(
int
rhs);
176
177
/// @brief Set text by lexigraphically converting rhs.
178
/// @param rhs The value to store in this text.
179
/// @return False if object is empty or there is not enough memory.
180
bool
Set(
unsigned
int
rhs);
181
182
/// @brief Set text by lexigraphically converting rhs.
183
/// @param rhs The value to store in this text.
184
/// @return False if object is empty or there is not enough memory.
185
bool
Set(
double
rhs);
186
187
/// @brief Set text by converting value to "true"/"false"
188
/// @param rhs The value to store in this text.
189
/// @return False if object is empty or there is not enough memory.
190
bool
Set(
bool
rhs);
191
#endif
192
193
/// @brief Set text (equivalent to set without error checking)
194
/// @param rhs The value to store in this text.
195
/// @return A reference to the modified NodeText to allow operator chaining.
196
NodeText& operator=(
const
Char8
* rhs);
197
198
/// @brief Set text (equivalent to set without error checking) by lexigraphically converting rhs.
199
/// @param rhs The value to store in this text.
200
/// @return A reference to the modified NodeText to allow operator chaining.
201
NodeText& operator=(
int
rhs);
202
203
/// @brief Set text (equivalent to set without error checking) by lexigraphically converting rhs.
204
/// @param rhs The value to store in this text.
205
/// @return A reference to the modified NodeText to allow operator chaining.
206
NodeText& operator=(
unsigned
int
rhs);
207
208
/// @brief Set text (equivalent to set without error checking) by lexigraphically converting rhs.
209
/// @param rhs The value to store in this text.
210
/// @return A reference to the modified NodeText to allow operator chaining.
211
NodeText& operator=(
double
rhs);
212
213
/// @brief Set text (equivalent to set without error checking)by converting value to "true"/"false"
214
/// @param rhs The value to store in this text.
215
/// @return A reference to the modified NodeText to allow operator chaining.
216
NodeText& operator=(
bool
rhs);
217
218
/// @brief Get the data node (NodePcdata or NodeCdata) for this object
219
/// @return A Node that contains this NodeText.
220
Node
data()
const
;
221
};
222
}
223
}
// /namespace Mezzanine
224
225
226
227
#endif // Include guard
228
229
/*
230
*
231
* Software, Files, Libraries and all other items referenced in this clause refers only
232
* to the contents of this file and associated documentation.
233
*
234
* Copyright © 2006-2012 Arseny Kapoulkine
235
*
236
* Permission is hereby granted, free of charge, to any person
237
* obtaining a copy of this software and associated documentation
238
* files (the "Software"), to deal in the Software without
239
* restriction, including without limitation the rights to use,
240
* copy, modify, merge, publish, distribute, sublicense, and/or sell
241
* copies of the Software, and to permit persons to whom the
242
* Software is furnished to do so, subject to the following
243
* conditions:
244
*
245
* The above copyright notice and this permission notice shall be
246
* included in all copies or substantial portions of the Software.
247
*
248
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
249
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
250
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
251
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
252
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
253
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
254
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
255
* OTHER DEALINGS IN THE SOFTWARE.
256
*/
Generated on Mon Jan 6 2014 20:58:06 for MezzanineEngine by
1.8.4