quickfix_ruby 1.14.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/ext/quickfix/Acceptor.cpp +248 -0
- data/ext/quickfix/Acceptor.h +127 -0
- data/ext/quickfix/Allocator.h +9 -0
- data/ext/quickfix/Application.h +127 -0
- data/ext/quickfix/AtomicCount.h +109 -0
- data/ext/quickfix/DOMDocument.h +74 -0
- data/ext/quickfix/DataDictionary.cpp +618 -0
- data/ext/quickfix/DataDictionary.h +539 -0
- data/ext/quickfix/DataDictionaryProvider.cpp +71 -0
- data/ext/quickfix/DataDictionaryProvider.h +70 -0
- data/ext/quickfix/DatabaseConnectionID.h +105 -0
- data/ext/quickfix/DatabaseConnectionPool.h +91 -0
- data/ext/quickfix/Dictionary.cpp +162 -0
- data/ext/quickfix/Dictionary.h +94 -0
- data/ext/quickfix/Event.h +95 -0
- data/ext/quickfix/Exceptions.h +299 -0
- data/ext/quickfix/Field.h +672 -0
- data/ext/quickfix/FieldConvertors.h +863 -0
- data/ext/quickfix/FieldMap.cpp +238 -0
- data/ext/quickfix/FieldMap.h +244 -0
- data/ext/quickfix/FieldNumbers.h +46 -0
- data/ext/quickfix/FieldTypes.cpp +64 -0
- data/ext/quickfix/FieldTypes.h +698 -0
- data/ext/quickfix/Fields.h +31 -0
- data/ext/quickfix/FileLog.cpp +200 -0
- data/ext/quickfix/FileLog.h +112 -0
- data/ext/quickfix/FileStore.cpp +332 -0
- data/ext/quickfix/FileStore.h +129 -0
- data/ext/quickfix/FixFieldNumbers.h +1537 -0
- data/ext/quickfix/FixFields.h +1538 -0
- data/ext/quickfix/FixValues.h +3281 -0
- data/ext/quickfix/FlexLexer.h +188 -0
- data/ext/quickfix/Group.cpp +64 -0
- data/ext/quickfix/Group.h +73 -0
- data/ext/quickfix/HtmlBuilder.h +186 -0
- data/ext/quickfix/HttpConnection.cpp +739 -0
- data/ext/quickfix/HttpConnection.h +78 -0
- data/ext/quickfix/HttpMessage.cpp +149 -0
- data/ext/quickfix/HttpMessage.h +133 -0
- data/ext/quickfix/HttpParser.cpp +49 -0
- data/ext/quickfix/HttpParser.h +54 -0
- data/ext/quickfix/HttpServer.cpp +169 -0
- data/ext/quickfix/HttpServer.h +78 -0
- data/ext/quickfix/Initiator.cpp +289 -0
- data/ext/quickfix/Initiator.h +149 -0
- data/ext/quickfix/Log.cpp +77 -0
- data/ext/quickfix/Log.h +179 -0
- data/ext/quickfix/Message.cpp +580 -0
- data/ext/quickfix/Message.h +370 -0
- data/ext/quickfix/MessageCracker.h +188 -0
- data/ext/quickfix/MessageSorters.cpp +105 -0
- data/ext/quickfix/MessageSorters.h +156 -0
- data/ext/quickfix/MessageStore.cpp +146 -0
- data/ext/quickfix/MessageStore.h +174 -0
- data/ext/quickfix/Mutex.h +131 -0
- data/ext/quickfix/MySQLConnection.h +194 -0
- data/ext/quickfix/MySQLLog.cpp +275 -0
- data/ext/quickfix/MySQLLog.h +145 -0
- data/ext/quickfix/MySQLStore.cpp +331 -0
- data/ext/quickfix/MySQLStore.h +142 -0
- data/ext/quickfix/NullStore.cpp +54 -0
- data/ext/quickfix/NullStore.h +99 -0
- data/ext/quickfix/OdbcConnection.h +266 -0
- data/ext/quickfix/OdbcLog.cpp +252 -0
- data/ext/quickfix/OdbcLog.h +117 -0
- data/ext/quickfix/OdbcStore.cpp +338 -0
- data/ext/quickfix/OdbcStore.h +113 -0
- data/ext/quickfix/PUGIXML_DOMDocument.cpp +112 -0
- data/ext/quickfix/PUGIXML_DOMDocument.h +81 -0
- data/ext/quickfix/Parser.cpp +103 -0
- data/ext/quickfix/Parser.h +57 -0
- data/ext/quickfix/PostgreSQLConnection.h +176 -0
- data/ext/quickfix/PostgreSQLLog.cpp +276 -0
- data/ext/quickfix/PostgreSQLLog.h +144 -0
- data/ext/quickfix/PostgreSQLStore.cpp +334 -0
- data/ext/quickfix/PostgreSQLStore.h +141 -0
- data/ext/quickfix/Queue.h +75 -0
- data/ext/quickfix/QuickfixRuby.cpp +252066 -0
- data/ext/quickfix/QuickfixRuby.h +34 -0
- data/ext/quickfix/Responder.h +43 -0
- data/ext/quickfix/Session.cpp +1487 -0
- data/ext/quickfix/Session.h +335 -0
- data/ext/quickfix/SessionFactory.cpp +274 -0
- data/ext/quickfix/SessionFactory.h +86 -0
- data/ext/quickfix/SessionID.h +170 -0
- data/ext/quickfix/SessionSettings.cpp +189 -0
- data/ext/quickfix/SessionSettings.h +171 -0
- data/ext/quickfix/SessionState.h +231 -0
- data/ext/quickfix/Settings.cpp +100 -0
- data/ext/quickfix/Settings.h +53 -0
- data/ext/quickfix/SharedArray.h +150 -0
- data/ext/quickfix/SocketAcceptor.cpp +222 -0
- data/ext/quickfix/SocketAcceptor.h +75 -0
- data/ext/quickfix/SocketConnection.cpp +238 -0
- data/ext/quickfix/SocketConnection.h +103 -0
- data/ext/quickfix/SocketConnector.cpp +116 -0
- data/ext/quickfix/SocketConnector.h +67 -0
- data/ext/quickfix/SocketInitiator.cpp +260 -0
- data/ext/quickfix/SocketInitiator.h +81 -0
- data/ext/quickfix/SocketMonitor.cpp +335 -0
- data/ext/quickfix/SocketMonitor.h +111 -0
- data/ext/quickfix/SocketServer.cpp +177 -0
- data/ext/quickfix/SocketServer.h +100 -0
- data/ext/quickfix/ThreadedSocketAcceptor.cpp +258 -0
- data/ext/quickfix/ThreadedSocketAcceptor.h +98 -0
- data/ext/quickfix/ThreadedSocketConnection.cpp +209 -0
- data/ext/quickfix/ThreadedSocketConnection.h +82 -0
- data/ext/quickfix/ThreadedSocketInitiator.cpp +268 -0
- data/ext/quickfix/ThreadedSocketInitiator.h +84 -0
- data/ext/quickfix/TimeRange.cpp +173 -0
- data/ext/quickfix/TimeRange.h +258 -0
- data/ext/quickfix/Utility.cpp +537 -0
- data/ext/quickfix/Utility.h +219 -0
- data/ext/quickfix/Values.h +62 -0
- data/ext/quickfix/config.h +0 -0
- data/ext/quickfix/config_windows.h +0 -0
- data/ext/quickfix/extconf.rb +12 -0
- data/ext/quickfix/index.h +37 -0
- data/ext/quickfix/pugiconfig.hpp +72 -0
- data/ext/quickfix/pugixml.cpp +10765 -0
- data/ext/quickfix/pugixml.hpp +1341 -0
- data/ext/quickfix/strptime.h +7 -0
- data/lib/quickfix40.rb +274 -0
- data/lib/quickfix41.rb +351 -0
- data/lib/quickfix42.rb +1184 -0
- data/lib/quickfix43.rb +3504 -0
- data/lib/quickfix44.rb +10721 -0
- data/lib/quickfix50.rb +13426 -0
- data/lib/quickfix50sp1.rb +15629 -0
- data/lib/quickfix50sp2.rb +17068 -0
- data/lib/quickfix_fields.rb +19853 -0
- data/lib/quickfix_ruby.rb +82 -0
- data/lib/quickfixt11.rb +70 -0
- data/spec/FIX40.xml +862 -0
- data/spec/FIX41.xml +1285 -0
- data/spec/FIX42.xml +2746 -0
- data/spec/FIX43.xml +4229 -0
- data/spec/FIX44.xml +6596 -0
- data/spec/FIX50.xml +8137 -0
- data/spec/FIX50SP1.xml +9496 -0
- data/spec/FIX50SP2.xml +10011 -0
- data/spec/FIXT11.xml +313 -0
- data/test/test_DataDictionaryTestCase.rb +268 -0
- data/test/test_DictionaryTestCase.rb +112 -0
- data/test/test_FieldBaseTestCase.rb +24 -0
- data/test/test_MessageTestCase.rb +368 -0
- data/test/test_SessionSettingsTestCase.rb +41 -0
- metadata +193 -0
@@ -0,0 +1,1341 @@
|
|
1
|
+
/**
|
2
|
+
* pugixml parser - version 1.4
|
3
|
+
* --------------------------------------------------------
|
4
|
+
* Copyright (C) 2006-2014, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
|
5
|
+
* Report bugs and download new versions at http://pugixml.org/
|
6
|
+
*
|
7
|
+
* This library is distributed under the MIT License. See notice at the end
|
8
|
+
* of this file.
|
9
|
+
*
|
10
|
+
* This work is based on the pugxml parser, which is:
|
11
|
+
* Copyright (C) 2003, by Kristen Wegner (kristen@tima.net)
|
12
|
+
*/
|
13
|
+
|
14
|
+
#ifndef PUGIXML_VERSION
|
15
|
+
// Define version macro; evaluates to major * 100 + minor so that it's safe to use in less-than comparisons
|
16
|
+
# define PUGIXML_VERSION 140
|
17
|
+
#endif
|
18
|
+
|
19
|
+
// Include user configuration file (this can define various configuration macros)
|
20
|
+
#include "pugiconfig.hpp"
|
21
|
+
|
22
|
+
#ifndef HEADER_PUGIXML_HPP
|
23
|
+
#define HEADER_PUGIXML_HPP
|
24
|
+
|
25
|
+
// Include stddef.h for size_t and ptrdiff_t
|
26
|
+
#include <stddef.h>
|
27
|
+
|
28
|
+
// Include exception header for XPath
|
29
|
+
#if !defined(PUGIXML_NO_XPATH) && !defined(PUGIXML_NO_EXCEPTIONS)
|
30
|
+
# include <exception>
|
31
|
+
#endif
|
32
|
+
|
33
|
+
// Include STL headers
|
34
|
+
#ifndef PUGIXML_NO_STL
|
35
|
+
# include <iterator>
|
36
|
+
# include <iosfwd>
|
37
|
+
# include <string>
|
38
|
+
#endif
|
39
|
+
|
40
|
+
// Macro for deprecated features
|
41
|
+
#ifndef PUGIXML_DEPRECATED
|
42
|
+
# if defined(__GNUC__)
|
43
|
+
# define PUGIXML_DEPRECATED __attribute__((deprecated))
|
44
|
+
# elif defined(_MSC_VER) && _MSC_VER >= 1300
|
45
|
+
# define PUGIXML_DEPRECATED __declspec(deprecated)
|
46
|
+
# else
|
47
|
+
# define PUGIXML_DEPRECATED
|
48
|
+
# endif
|
49
|
+
#endif
|
50
|
+
|
51
|
+
// If no API is defined, assume default
|
52
|
+
#ifndef PUGIXML_API
|
53
|
+
# define PUGIXML_API
|
54
|
+
#endif
|
55
|
+
|
56
|
+
// If no API for classes is defined, assume default
|
57
|
+
#ifndef PUGIXML_CLASS
|
58
|
+
# define PUGIXML_CLASS PUGIXML_API
|
59
|
+
#endif
|
60
|
+
|
61
|
+
// If no API for functions is defined, assume default
|
62
|
+
#ifndef PUGIXML_FUNCTION
|
63
|
+
# define PUGIXML_FUNCTION PUGIXML_API
|
64
|
+
#endif
|
65
|
+
|
66
|
+
// If the platform is known to have long long support, enable long long functions
|
67
|
+
#ifndef PUGIXML_HAS_LONG_LONG
|
68
|
+
# if defined(__cplusplus) && __cplusplus >= 201103
|
69
|
+
# define PUGIXML_HAS_LONG_LONG
|
70
|
+
# elif defined(_MSC_VER) && _MSC_VER >= 1400
|
71
|
+
# define PUGIXML_HAS_LONG_LONG
|
72
|
+
# endif
|
73
|
+
#endif
|
74
|
+
|
75
|
+
// Character interface macros
|
76
|
+
#ifdef PUGIXML_WCHAR_MODE
|
77
|
+
# define PUGIXML_TEXT(t) L ## t
|
78
|
+
# define PUGIXML_CHAR wchar_t
|
79
|
+
#else
|
80
|
+
# define PUGIXML_TEXT(t) t
|
81
|
+
# define PUGIXML_CHAR char
|
82
|
+
#endif
|
83
|
+
|
84
|
+
namespace pugi
|
85
|
+
{
|
86
|
+
// Character type used for all internal storage and operations; depends on PUGIXML_WCHAR_MODE
|
87
|
+
typedef PUGIXML_CHAR char_t;
|
88
|
+
|
89
|
+
#ifndef PUGIXML_NO_STL
|
90
|
+
// String type used for operations that work with STL string; depends on PUGIXML_WCHAR_MODE
|
91
|
+
typedef std::basic_string<PUGIXML_CHAR, std::char_traits<PUGIXML_CHAR>, std::allocator<PUGIXML_CHAR> > string_t;
|
92
|
+
#endif
|
93
|
+
}
|
94
|
+
|
95
|
+
// The PugiXML namespace
|
96
|
+
namespace pugi
|
97
|
+
{
|
98
|
+
// Tree node types
|
99
|
+
enum xml_node_type
|
100
|
+
{
|
101
|
+
node_null, // Empty (null) node handle
|
102
|
+
node_document, // A document tree's absolute root
|
103
|
+
node_element, // Element tag, i.e. '<node/>'
|
104
|
+
node_pcdata, // Plain character data, i.e. 'text'
|
105
|
+
node_cdata, // Character data, i.e. '<![CDATA[text]]>'
|
106
|
+
node_comment, // Comment tag, i.e. '<!-- text -->'
|
107
|
+
node_pi, // Processing instruction, i.e. '<?name?>'
|
108
|
+
node_declaration, // Document declaration, i.e. '<?xml version="1.0"?>'
|
109
|
+
node_doctype // Document type declaration, i.e. '<!DOCTYPE doc>'
|
110
|
+
};
|
111
|
+
|
112
|
+
// Parsing options
|
113
|
+
|
114
|
+
// Minimal parsing mode (equivalent to turning all other flags off).
|
115
|
+
// Only elements and PCDATA sections are added to the DOM tree, no text conversions are performed.
|
116
|
+
const unsigned int parse_minimal = 0x0000;
|
117
|
+
|
118
|
+
// This flag determines if processing instructions (node_pi) are added to the DOM tree. This flag is off by default.
|
119
|
+
const unsigned int parse_pi = 0x0001;
|
120
|
+
|
121
|
+
// This flag determines if comments (node_comment) are added to the DOM tree. This flag is off by default.
|
122
|
+
const unsigned int parse_comments = 0x0002;
|
123
|
+
|
124
|
+
// This flag determines if CDATA sections (node_cdata) are added to the DOM tree. This flag is on by default.
|
125
|
+
const unsigned int parse_cdata = 0x0004;
|
126
|
+
|
127
|
+
// This flag determines if plain character data (node_pcdata) that consist only of whitespace are added to the DOM tree.
|
128
|
+
// This flag is off by default; turning it on usually results in slower parsing and more memory consumption.
|
129
|
+
const unsigned int parse_ws_pcdata = 0x0008;
|
130
|
+
|
131
|
+
// This flag determines if character and entity references are expanded during parsing. This flag is on by default.
|
132
|
+
const unsigned int parse_escapes = 0x0010;
|
133
|
+
|
134
|
+
// This flag determines if EOL characters are normalized (converted to #xA) during parsing. This flag is on by default.
|
135
|
+
const unsigned int parse_eol = 0x0020;
|
136
|
+
|
137
|
+
// This flag determines if attribute values are normalized using CDATA normalization rules during parsing. This flag is on by default.
|
138
|
+
const unsigned int parse_wconv_attribute = 0x0040;
|
139
|
+
|
140
|
+
// This flag determines if attribute values are normalized using NMTOKENS normalization rules during parsing. This flag is off by default.
|
141
|
+
const unsigned int parse_wnorm_attribute = 0x0080;
|
142
|
+
|
143
|
+
// This flag determines if document declaration (node_declaration) is added to the DOM tree. This flag is off by default.
|
144
|
+
const unsigned int parse_declaration = 0x0100;
|
145
|
+
|
146
|
+
// This flag determines if document type declaration (node_doctype) is added to the DOM tree. This flag is off by default.
|
147
|
+
const unsigned int parse_doctype = 0x0200;
|
148
|
+
|
149
|
+
// This flag determines if plain character data (node_pcdata) that is the only child of the parent node and that consists only
|
150
|
+
// of whitespace is added to the DOM tree.
|
151
|
+
// This flag is off by default; turning it on may result in slower parsing and more memory consumption.
|
152
|
+
const unsigned int parse_ws_pcdata_single = 0x0400;
|
153
|
+
|
154
|
+
// This flag determines if leading and trailing whitespace is to be removed from plain character data. This flag is off by default.
|
155
|
+
const unsigned int parse_trim_pcdata = 0x0800;
|
156
|
+
|
157
|
+
// This flag determines if plain character data that does not have a parent node is added to the DOM tree, and if an empty document
|
158
|
+
// is a valid document. This flag is off by default.
|
159
|
+
const unsigned int parse_fragment = 0x1000;
|
160
|
+
|
161
|
+
// The default parsing mode.
|
162
|
+
// Elements, PCDATA and CDATA sections are added to the DOM tree, character/reference entities are expanded,
|
163
|
+
// End-of-Line characters are normalized, attribute values are normalized using CDATA normalization rules.
|
164
|
+
const unsigned int parse_default = parse_cdata | parse_escapes | parse_wconv_attribute | parse_eol;
|
165
|
+
|
166
|
+
// The full parsing mode.
|
167
|
+
// Nodes of all types are added to the DOM tree, character/reference entities are expanded,
|
168
|
+
// End-of-Line characters are normalized, attribute values are normalized using CDATA normalization rules.
|
169
|
+
const unsigned int parse_full = parse_default | parse_pi | parse_comments | parse_declaration | parse_doctype;
|
170
|
+
|
171
|
+
// These flags determine the encoding of input data for XML document
|
172
|
+
enum xml_encoding
|
173
|
+
{
|
174
|
+
encoding_auto, // Auto-detect input encoding using BOM or < / <? detection; use UTF8 if BOM is not found
|
175
|
+
encoding_utf8, // UTF8 encoding
|
176
|
+
encoding_utf16_le, // Little-endian UTF16
|
177
|
+
encoding_utf16_be, // Big-endian UTF16
|
178
|
+
encoding_utf16, // UTF16 with native endianness
|
179
|
+
encoding_utf32_le, // Little-endian UTF32
|
180
|
+
encoding_utf32_be, // Big-endian UTF32
|
181
|
+
encoding_utf32, // UTF32 with native endianness
|
182
|
+
encoding_wchar, // The same encoding wchar_t has (either UTF16 or UTF32)
|
183
|
+
encoding_latin1
|
184
|
+
};
|
185
|
+
|
186
|
+
// Formatting flags
|
187
|
+
|
188
|
+
// Indent the nodes that are written to output stream with as many indentation strings as deep the node is in DOM tree. This flag is on by default.
|
189
|
+
const unsigned int format_indent = 0x01;
|
190
|
+
|
191
|
+
// Write encoding-specific BOM to the output stream. This flag is off by default.
|
192
|
+
const unsigned int format_write_bom = 0x02;
|
193
|
+
|
194
|
+
// Use raw output mode (no indentation and no line breaks are written). This flag is off by default.
|
195
|
+
const unsigned int format_raw = 0x04;
|
196
|
+
|
197
|
+
// Omit default XML declaration even if there is no declaration in the document. This flag is off by default.
|
198
|
+
const unsigned int format_no_declaration = 0x08;
|
199
|
+
|
200
|
+
// Don't escape attribute values and PCDATA contents. This flag is off by default.
|
201
|
+
const unsigned int format_no_escapes = 0x10;
|
202
|
+
|
203
|
+
// Open file using text mode in xml_document::save_file. This enables special character (i.e. new-line) conversions on some systems. This flag is off by default.
|
204
|
+
const unsigned int format_save_file_text = 0x20;
|
205
|
+
|
206
|
+
// The default set of formatting flags.
|
207
|
+
// Nodes are indented depending on their depth in DOM tree, a default declaration is output if document has none.
|
208
|
+
const unsigned int format_default = format_indent;
|
209
|
+
|
210
|
+
// Forward declarations
|
211
|
+
struct xml_attribute_struct;
|
212
|
+
struct xml_node_struct;
|
213
|
+
|
214
|
+
class xml_node_iterator;
|
215
|
+
class xml_attribute_iterator;
|
216
|
+
class xml_named_node_iterator;
|
217
|
+
|
218
|
+
class xml_tree_walker;
|
219
|
+
|
220
|
+
struct xml_parse_result;
|
221
|
+
|
222
|
+
class xml_node;
|
223
|
+
|
224
|
+
class xml_text;
|
225
|
+
|
226
|
+
#ifndef PUGIXML_NO_XPATH
|
227
|
+
class xpath_node;
|
228
|
+
class xpath_node_set;
|
229
|
+
class xpath_query;
|
230
|
+
class xpath_variable_set;
|
231
|
+
#endif
|
232
|
+
|
233
|
+
// Range-based for loop support
|
234
|
+
template <typename It> class xml_object_range
|
235
|
+
{
|
236
|
+
public:
|
237
|
+
typedef It const_iterator;
|
238
|
+
typedef It iterator;
|
239
|
+
|
240
|
+
xml_object_range(It b, It e): _begin(b), _end(e)
|
241
|
+
{
|
242
|
+
}
|
243
|
+
|
244
|
+
It begin() const { return _begin; }
|
245
|
+
It end() const { return _end; }
|
246
|
+
|
247
|
+
private:
|
248
|
+
It _begin, _end;
|
249
|
+
};
|
250
|
+
|
251
|
+
// Writer interface for node printing (see xml_node::print)
|
252
|
+
class PUGIXML_CLASS xml_writer
|
253
|
+
{
|
254
|
+
public:
|
255
|
+
virtual ~xml_writer() {}
|
256
|
+
|
257
|
+
// Write memory chunk into stream/file/whatever
|
258
|
+
virtual void write(const void* data, size_t size) = 0;
|
259
|
+
};
|
260
|
+
|
261
|
+
// xml_writer implementation for FILE*
|
262
|
+
class PUGIXML_CLASS xml_writer_file: public xml_writer
|
263
|
+
{
|
264
|
+
public:
|
265
|
+
// Construct writer from a FILE* object; void* is used to avoid header dependencies on stdio
|
266
|
+
xml_writer_file(void* file);
|
267
|
+
|
268
|
+
virtual void write(const void* data, size_t size);
|
269
|
+
|
270
|
+
private:
|
271
|
+
void* file;
|
272
|
+
};
|
273
|
+
|
274
|
+
#ifndef PUGIXML_NO_STL
|
275
|
+
// xml_writer implementation for streams
|
276
|
+
class PUGIXML_CLASS xml_writer_stream: public xml_writer
|
277
|
+
{
|
278
|
+
public:
|
279
|
+
// Construct writer from an output stream object
|
280
|
+
xml_writer_stream(std::basic_ostream<char, std::char_traits<char> >& stream);
|
281
|
+
xml_writer_stream(std::basic_ostream<wchar_t, std::char_traits<wchar_t> >& stream);
|
282
|
+
|
283
|
+
virtual void write(const void* data, size_t size);
|
284
|
+
|
285
|
+
private:
|
286
|
+
std::basic_ostream<char, std::char_traits<char> >* narrow_stream;
|
287
|
+
std::basic_ostream<wchar_t, std::char_traits<wchar_t> >* wide_stream;
|
288
|
+
};
|
289
|
+
#endif
|
290
|
+
|
291
|
+
// A light-weight handle for manipulating attributes in DOM tree
|
292
|
+
class PUGIXML_CLASS xml_attribute
|
293
|
+
{
|
294
|
+
friend class xml_attribute_iterator;
|
295
|
+
friend class xml_node;
|
296
|
+
|
297
|
+
private:
|
298
|
+
xml_attribute_struct* _attr;
|
299
|
+
|
300
|
+
typedef void (*unspecified_bool_type)(xml_attribute***);
|
301
|
+
|
302
|
+
public:
|
303
|
+
// Default constructor. Constructs an empty attribute.
|
304
|
+
xml_attribute();
|
305
|
+
|
306
|
+
// Constructs attribute from internal pointer
|
307
|
+
explicit xml_attribute(xml_attribute_struct* attr);
|
308
|
+
|
309
|
+
// Safe bool conversion operator
|
310
|
+
operator unspecified_bool_type() const;
|
311
|
+
|
312
|
+
// Borland C++ workaround
|
313
|
+
bool operator!() const;
|
314
|
+
|
315
|
+
// Comparison operators (compares wrapped attribute pointers)
|
316
|
+
bool operator==(const xml_attribute& r) const;
|
317
|
+
bool operator!=(const xml_attribute& r) const;
|
318
|
+
bool operator<(const xml_attribute& r) const;
|
319
|
+
bool operator>(const xml_attribute& r) const;
|
320
|
+
bool operator<=(const xml_attribute& r) const;
|
321
|
+
bool operator>=(const xml_attribute& r) const;
|
322
|
+
|
323
|
+
// Check if attribute is empty
|
324
|
+
bool empty() const;
|
325
|
+
|
326
|
+
// Get attribute name/value, or "" if attribute is empty
|
327
|
+
const char_t* name() const;
|
328
|
+
const char_t* value() const;
|
329
|
+
|
330
|
+
// Get attribute value, or the default value if attribute is empty
|
331
|
+
const char_t* as_string(const char_t* def = PUGIXML_TEXT("")) const;
|
332
|
+
|
333
|
+
// Get attribute value as a number, or the default value if conversion did not succeed or attribute is empty
|
334
|
+
int as_int(int def = 0) const;
|
335
|
+
unsigned int as_uint(unsigned int def = 0) const;
|
336
|
+
double as_double(double def = 0) const;
|
337
|
+
float as_float(float def = 0) const;
|
338
|
+
|
339
|
+
#ifdef PUGIXML_HAS_LONG_LONG
|
340
|
+
long long as_llong(long long def = 0) const;
|
341
|
+
unsigned long long as_ullong(unsigned long long def = 0) const;
|
342
|
+
#endif
|
343
|
+
|
344
|
+
// Get attribute value as bool (returns true if first character is in '1tTyY' set), or the default value if attribute is empty
|
345
|
+
bool as_bool(bool def = false) const;
|
346
|
+
|
347
|
+
// Set attribute name/value (returns false if attribute is empty or there is not enough memory)
|
348
|
+
bool set_name(const char_t* rhs);
|
349
|
+
bool set_value(const char_t* rhs);
|
350
|
+
|
351
|
+
// Set attribute value with type conversion (numbers are converted to strings, boolean is converted to "true"/"false")
|
352
|
+
bool set_value(int rhs);
|
353
|
+
bool set_value(unsigned int rhs);
|
354
|
+
bool set_value(double rhs);
|
355
|
+
bool set_value(bool rhs);
|
356
|
+
|
357
|
+
#ifdef PUGIXML_HAS_LONG_LONG
|
358
|
+
bool set_value(long long rhs);
|
359
|
+
bool set_value(unsigned long long rhs);
|
360
|
+
#endif
|
361
|
+
|
362
|
+
// Set attribute value (equivalent to set_value without error checking)
|
363
|
+
xml_attribute& operator=(const char_t* rhs);
|
364
|
+
xml_attribute& operator=(int rhs);
|
365
|
+
xml_attribute& operator=(unsigned int rhs);
|
366
|
+
xml_attribute& operator=(double rhs);
|
367
|
+
xml_attribute& operator=(bool rhs);
|
368
|
+
|
369
|
+
#ifdef PUGIXML_HAS_LONG_LONG
|
370
|
+
xml_attribute& operator=(long long rhs);
|
371
|
+
xml_attribute& operator=(unsigned long long rhs);
|
372
|
+
#endif
|
373
|
+
|
374
|
+
// Get next/previous attribute in the attribute list of the parent node
|
375
|
+
xml_attribute next_attribute() const;
|
376
|
+
xml_attribute previous_attribute() const;
|
377
|
+
|
378
|
+
// Get hash value (unique for handles to the same object)
|
379
|
+
size_t hash_value() const;
|
380
|
+
|
381
|
+
// Get internal pointer
|
382
|
+
xml_attribute_struct* internal_object() const;
|
383
|
+
};
|
384
|
+
|
385
|
+
#ifdef __BORLANDC__
|
386
|
+
// Borland C++ workaround
|
387
|
+
bool PUGIXML_FUNCTION operator&&(const xml_attribute& lhs, bool rhs);
|
388
|
+
bool PUGIXML_FUNCTION operator||(const xml_attribute& lhs, bool rhs);
|
389
|
+
#endif
|
390
|
+
|
391
|
+
// A light-weight handle for manipulating nodes in DOM tree
|
392
|
+
class PUGIXML_CLASS xml_node
|
393
|
+
{
|
394
|
+
friend class xml_attribute_iterator;
|
395
|
+
friend class xml_node_iterator;
|
396
|
+
friend class xml_named_node_iterator;
|
397
|
+
|
398
|
+
protected:
|
399
|
+
xml_node_struct* _root;
|
400
|
+
|
401
|
+
typedef void (*unspecified_bool_type)(xml_node***);
|
402
|
+
|
403
|
+
public:
|
404
|
+
// Default constructor. Constructs an empty node.
|
405
|
+
xml_node();
|
406
|
+
|
407
|
+
// Constructs node from internal pointer
|
408
|
+
explicit xml_node(xml_node_struct* p);
|
409
|
+
|
410
|
+
// Safe bool conversion operator
|
411
|
+
operator unspecified_bool_type() const;
|
412
|
+
|
413
|
+
// Borland C++ workaround
|
414
|
+
bool operator!() const;
|
415
|
+
|
416
|
+
// Comparison operators (compares wrapped node pointers)
|
417
|
+
bool operator==(const xml_node& r) const;
|
418
|
+
bool operator!=(const xml_node& r) const;
|
419
|
+
bool operator<(const xml_node& r) const;
|
420
|
+
bool operator>(const xml_node& r) const;
|
421
|
+
bool operator<=(const xml_node& r) const;
|
422
|
+
bool operator>=(const xml_node& r) const;
|
423
|
+
|
424
|
+
// Check if node is empty.
|
425
|
+
bool empty() const;
|
426
|
+
|
427
|
+
// Get node type
|
428
|
+
xml_node_type type() const;
|
429
|
+
|
430
|
+
// Get node name, or "" if node is empty or it has no name
|
431
|
+
const char_t* name() const;
|
432
|
+
|
433
|
+
// Get node value, or "" if node is empty or it has no value
|
434
|
+
// Note: For <node>text</node> node.value() does not return "text"! Use child_value() or text() methods to access text inside nodes.
|
435
|
+
const char_t* value() const;
|
436
|
+
|
437
|
+
// Get attribute list
|
438
|
+
xml_attribute first_attribute() const;
|
439
|
+
xml_attribute last_attribute() const;
|
440
|
+
|
441
|
+
// Get children list
|
442
|
+
xml_node first_child() const;
|
443
|
+
xml_node last_child() const;
|
444
|
+
|
445
|
+
// Get next/previous sibling in the children list of the parent node
|
446
|
+
xml_node next_sibling() const;
|
447
|
+
xml_node previous_sibling() const;
|
448
|
+
|
449
|
+
// Get parent node
|
450
|
+
xml_node parent() const;
|
451
|
+
|
452
|
+
// Get root of DOM tree this node belongs to
|
453
|
+
xml_node root() const;
|
454
|
+
|
455
|
+
// Get text object for the current node
|
456
|
+
xml_text text() const;
|
457
|
+
|
458
|
+
// Get child, attribute or next/previous sibling with the specified name
|
459
|
+
xml_node child(const char_t* name) const;
|
460
|
+
xml_attribute attribute(const char_t* name) const;
|
461
|
+
xml_node next_sibling(const char_t* name) const;
|
462
|
+
xml_node previous_sibling(const char_t* name) const;
|
463
|
+
|
464
|
+
// Get child value of current node; that is, value of the first child node of type PCDATA/CDATA
|
465
|
+
const char_t* child_value() const;
|
466
|
+
|
467
|
+
// Get child value of child with specified name. Equivalent to child(name).child_value().
|
468
|
+
const char_t* child_value(const char_t* name) const;
|
469
|
+
|
470
|
+
// Set node name/value (returns false if node is empty, there is not enough memory, or node can not have name/value)
|
471
|
+
bool set_name(const char_t* rhs);
|
472
|
+
bool set_value(const char_t* rhs);
|
473
|
+
|
474
|
+
// Add attribute with specified name. Returns added attribute, or empty attribute on errors.
|
475
|
+
xml_attribute append_attribute(const char_t* name);
|
476
|
+
xml_attribute prepend_attribute(const char_t* name);
|
477
|
+
xml_attribute insert_attribute_after(const char_t* name, const xml_attribute& attr);
|
478
|
+
xml_attribute insert_attribute_before(const char_t* name, const xml_attribute& attr);
|
479
|
+
|
480
|
+
// Add a copy of the specified attribute. Returns added attribute, or empty attribute on errors.
|
481
|
+
xml_attribute append_copy(const xml_attribute& proto);
|
482
|
+
xml_attribute prepend_copy(const xml_attribute& proto);
|
483
|
+
xml_attribute insert_copy_after(const xml_attribute& proto, const xml_attribute& attr);
|
484
|
+
xml_attribute insert_copy_before(const xml_attribute& proto, const xml_attribute& attr);
|
485
|
+
|
486
|
+
// Add child node with specified type. Returns added node, or empty node on errors.
|
487
|
+
xml_node append_child(xml_node_type type = node_element);
|
488
|
+
xml_node prepend_child(xml_node_type type = node_element);
|
489
|
+
xml_node insert_child_after(xml_node_type type, const xml_node& node);
|
490
|
+
xml_node insert_child_before(xml_node_type type, const xml_node& node);
|
491
|
+
|
492
|
+
// Add child element with specified name. Returns added node, or empty node on errors.
|
493
|
+
xml_node append_child(const char_t* name);
|
494
|
+
xml_node prepend_child(const char_t* name);
|
495
|
+
xml_node insert_child_after(const char_t* name, const xml_node& node);
|
496
|
+
xml_node insert_child_before(const char_t* name, const xml_node& node);
|
497
|
+
|
498
|
+
// Add a copy of the specified node as a child. Returns added node, or empty node on errors.
|
499
|
+
xml_node append_copy(const xml_node& proto);
|
500
|
+
xml_node prepend_copy(const xml_node& proto);
|
501
|
+
xml_node insert_copy_after(const xml_node& proto, const xml_node& node);
|
502
|
+
xml_node insert_copy_before(const xml_node& proto, const xml_node& node);
|
503
|
+
|
504
|
+
// Move the specified node to become a child of this node. Returns moved node, or empty node on errors.
|
505
|
+
xml_node append_move(const xml_node& moved);
|
506
|
+
xml_node prepend_move(const xml_node& moved);
|
507
|
+
xml_node insert_move_after(const xml_node& moved, const xml_node& node);
|
508
|
+
xml_node insert_move_before(const xml_node& moved, const xml_node& node);
|
509
|
+
|
510
|
+
// Remove specified attribute
|
511
|
+
bool remove_attribute(const xml_attribute& a);
|
512
|
+
bool remove_attribute(const char_t* name);
|
513
|
+
|
514
|
+
// Remove specified child
|
515
|
+
bool remove_child(const xml_node& n);
|
516
|
+
bool remove_child(const char_t* name);
|
517
|
+
|
518
|
+
// Parses buffer as an XML document fragment and appends all nodes as children of the current node.
|
519
|
+
// Copies/converts the buffer, so it may be deleted or changed after the function returns.
|
520
|
+
// Note: append_buffer allocates memory that has the lifetime of the owning document; removing the appended nodes does not immediately reclaim that memory.
|
521
|
+
xml_parse_result append_buffer(const void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
|
522
|
+
|
523
|
+
// Find attribute using predicate. Returns first attribute for which predicate returned true.
|
524
|
+
template <typename Predicate> xml_attribute find_attribute(Predicate pred) const
|
525
|
+
{
|
526
|
+
if (!_root) return xml_attribute();
|
527
|
+
|
528
|
+
for (xml_attribute attrib = first_attribute(); attrib; attrib = attrib.next_attribute())
|
529
|
+
if (pred(attrib))
|
530
|
+
return attrib;
|
531
|
+
|
532
|
+
return xml_attribute();
|
533
|
+
}
|
534
|
+
|
535
|
+
// Find child node using predicate. Returns first child for which predicate returned true.
|
536
|
+
template <typename Predicate> xml_node find_child(Predicate pred) const
|
537
|
+
{
|
538
|
+
if (!_root) return xml_node();
|
539
|
+
|
540
|
+
for (xml_node node = first_child(); node; node = node.next_sibling())
|
541
|
+
if (pred(node))
|
542
|
+
return node;
|
543
|
+
|
544
|
+
return xml_node();
|
545
|
+
}
|
546
|
+
|
547
|
+
// Find node from subtree using predicate. Returns first node from subtree (depth-first), for which predicate returned true.
|
548
|
+
template <typename Predicate> xml_node find_node(Predicate pred) const
|
549
|
+
{
|
550
|
+
if (!_root) return xml_node();
|
551
|
+
|
552
|
+
xml_node cur = first_child();
|
553
|
+
|
554
|
+
while (cur._root && cur._root != _root)
|
555
|
+
{
|
556
|
+
if (pred(cur)) return cur;
|
557
|
+
|
558
|
+
if (cur.first_child()) cur = cur.first_child();
|
559
|
+
else if (cur.next_sibling()) cur = cur.next_sibling();
|
560
|
+
else
|
561
|
+
{
|
562
|
+
while (!cur.next_sibling() && cur._root != _root) cur = cur.parent();
|
563
|
+
|
564
|
+
if (cur._root != _root) cur = cur.next_sibling();
|
565
|
+
}
|
566
|
+
}
|
567
|
+
|
568
|
+
return xml_node();
|
569
|
+
}
|
570
|
+
|
571
|
+
// Find child node by attribute name/value
|
572
|
+
xml_node find_child_by_attribute(const char_t* name, const char_t* attr_name, const char_t* attr_value) const;
|
573
|
+
xml_node find_child_by_attribute(const char_t* attr_name, const char_t* attr_value) const;
|
574
|
+
|
575
|
+
#ifndef PUGIXML_NO_STL
|
576
|
+
// Get the absolute node path from root as a text string.
|
577
|
+
string_t path(char_t delimiter = '/') const;
|
578
|
+
#endif
|
579
|
+
|
580
|
+
// Search for a node by path consisting of node names and . or .. elements.
|
581
|
+
xml_node first_element_by_path(const char_t* path, char_t delimiter = '/') const;
|
582
|
+
|
583
|
+
// Recursively traverse subtree with xml_tree_walker
|
584
|
+
bool traverse(xml_tree_walker& walker);
|
585
|
+
|
586
|
+
#ifndef PUGIXML_NO_XPATH
|
587
|
+
// Select single node by evaluating XPath query. Returns first node from the resulting node set.
|
588
|
+
xpath_node select_single_node(const char_t* query, xpath_variable_set* variables = 0) const;
|
589
|
+
xpath_node select_single_node(const xpath_query& query) const;
|
590
|
+
|
591
|
+
// Select node set by evaluating XPath query
|
592
|
+
xpath_node_set select_nodes(const char_t* query, xpath_variable_set* variables = 0) const;
|
593
|
+
xpath_node_set select_nodes(const xpath_query& query) const;
|
594
|
+
#endif
|
595
|
+
|
596
|
+
// Print subtree using a writer object
|
597
|
+
void print(xml_writer& writer, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto, unsigned int depth = 0) const;
|
598
|
+
|
599
|
+
#ifndef PUGIXML_NO_STL
|
600
|
+
// Print subtree to stream
|
601
|
+
void print(std::basic_ostream<char, std::char_traits<char> >& os, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto, unsigned int depth = 0) const;
|
602
|
+
void print(std::basic_ostream<wchar_t, std::char_traits<wchar_t> >& os, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, unsigned int depth = 0) const;
|
603
|
+
#endif
|
604
|
+
|
605
|
+
// Child nodes iterators
|
606
|
+
typedef xml_node_iterator iterator;
|
607
|
+
|
608
|
+
iterator begin() const;
|
609
|
+
iterator end() const;
|
610
|
+
|
611
|
+
// Attribute iterators
|
612
|
+
typedef xml_attribute_iterator attribute_iterator;
|
613
|
+
|
614
|
+
attribute_iterator attributes_begin() const;
|
615
|
+
attribute_iterator attributes_end() const;
|
616
|
+
|
617
|
+
// Range-based for support
|
618
|
+
xml_object_range<xml_node_iterator> children() const;
|
619
|
+
xml_object_range<xml_named_node_iterator> children(const char_t* name) const;
|
620
|
+
xml_object_range<xml_attribute_iterator> attributes() const;
|
621
|
+
|
622
|
+
// Get node offset in parsed file/string (in char_t units) for debugging purposes
|
623
|
+
ptrdiff_t offset_debug() const;
|
624
|
+
|
625
|
+
// Get hash value (unique for handles to the same object)
|
626
|
+
size_t hash_value() const;
|
627
|
+
|
628
|
+
// Get internal pointer
|
629
|
+
xml_node_struct* internal_object() const;
|
630
|
+
};
|
631
|
+
|
632
|
+
#ifdef __BORLANDC__
|
633
|
+
// Borland C++ workaround
|
634
|
+
bool PUGIXML_FUNCTION operator&&(const xml_node& lhs, bool rhs);
|
635
|
+
bool PUGIXML_FUNCTION operator||(const xml_node& lhs, bool rhs);
|
636
|
+
#endif
|
637
|
+
|
638
|
+
// A helper for working with text inside PCDATA nodes
|
639
|
+
class PUGIXML_CLASS xml_text
|
640
|
+
{
|
641
|
+
friend class xml_node;
|
642
|
+
|
643
|
+
xml_node_struct* _root;
|
644
|
+
|
645
|
+
typedef void (*unspecified_bool_type)(xml_text***);
|
646
|
+
|
647
|
+
explicit xml_text(xml_node_struct* root);
|
648
|
+
|
649
|
+
xml_node_struct* _data_new();
|
650
|
+
xml_node_struct* _data() const;
|
651
|
+
|
652
|
+
public:
|
653
|
+
// Default constructor. Constructs an empty object.
|
654
|
+
xml_text();
|
655
|
+
|
656
|
+
// Safe bool conversion operator
|
657
|
+
operator unspecified_bool_type() const;
|
658
|
+
|
659
|
+
// Borland C++ workaround
|
660
|
+
bool operator!() const;
|
661
|
+
|
662
|
+
// Check if text object is empty
|
663
|
+
bool empty() const;
|
664
|
+
|
665
|
+
// Get text, or "" if object is empty
|
666
|
+
const char_t* get() const;
|
667
|
+
|
668
|
+
// Get text, or the default value if object is empty
|
669
|
+
const char_t* as_string(const char_t* def = PUGIXML_TEXT("")) const;
|
670
|
+
|
671
|
+
// Get text as a number, or the default value if conversion did not succeed or object is empty
|
672
|
+
int as_int(int def = 0) const;
|
673
|
+
unsigned int as_uint(unsigned int def = 0) const;
|
674
|
+
double as_double(double def = 0) const;
|
675
|
+
float as_float(float def = 0) const;
|
676
|
+
|
677
|
+
#ifdef PUGIXML_HAS_LONG_LONG
|
678
|
+
long long as_llong(long long def = 0) const;
|
679
|
+
unsigned long long as_ullong(unsigned long long def = 0) const;
|
680
|
+
#endif
|
681
|
+
|
682
|
+
// Get text as bool (returns true if first character is in '1tTyY' set), or the default value if object is empty
|
683
|
+
bool as_bool(bool def = false) const;
|
684
|
+
|
685
|
+
// Set text (returns false if object is empty or there is not enough memory)
|
686
|
+
bool set(const char_t* rhs);
|
687
|
+
|
688
|
+
// Set text with type conversion (numbers are converted to strings, boolean is converted to "true"/"false")
|
689
|
+
bool set(int rhs);
|
690
|
+
bool set(unsigned int rhs);
|
691
|
+
bool set(double rhs);
|
692
|
+
bool set(bool rhs);
|
693
|
+
|
694
|
+
#ifdef PUGIXML_HAS_LONG_LONG
|
695
|
+
bool set(long long rhs);
|
696
|
+
bool set(unsigned long long rhs);
|
697
|
+
#endif
|
698
|
+
|
699
|
+
// Set text (equivalent to set without error checking)
|
700
|
+
xml_text& operator=(const char_t* rhs);
|
701
|
+
xml_text& operator=(int rhs);
|
702
|
+
xml_text& operator=(unsigned int rhs);
|
703
|
+
xml_text& operator=(double rhs);
|
704
|
+
xml_text& operator=(bool rhs);
|
705
|
+
|
706
|
+
#ifdef PUGIXML_HAS_LONG_LONG
|
707
|
+
xml_text& operator=(long long rhs);
|
708
|
+
xml_text& operator=(unsigned long long rhs);
|
709
|
+
#endif
|
710
|
+
|
711
|
+
// Get the data node (node_pcdata or node_cdata) for this object
|
712
|
+
xml_node data() const;
|
713
|
+
};
|
714
|
+
|
715
|
+
#ifdef __BORLANDC__
|
716
|
+
// Borland C++ workaround
|
717
|
+
bool PUGIXML_FUNCTION operator&&(const xml_text& lhs, bool rhs);
|
718
|
+
bool PUGIXML_FUNCTION operator||(const xml_text& lhs, bool rhs);
|
719
|
+
#endif
|
720
|
+
|
721
|
+
// Child node iterator (a bidirectional iterator over a collection of xml_node)
|
722
|
+
class PUGIXML_CLASS xml_node_iterator
|
723
|
+
{
|
724
|
+
friend class xml_node;
|
725
|
+
|
726
|
+
private:
|
727
|
+
mutable xml_node _wrap;
|
728
|
+
xml_node _parent;
|
729
|
+
|
730
|
+
xml_node_iterator(xml_node_struct* ref, xml_node_struct* parent);
|
731
|
+
|
732
|
+
public:
|
733
|
+
// Iterator traits
|
734
|
+
typedef ptrdiff_t difference_type;
|
735
|
+
typedef xml_node value_type;
|
736
|
+
typedef xml_node* pointer;
|
737
|
+
typedef xml_node& reference;
|
738
|
+
|
739
|
+
#ifndef PUGIXML_NO_STL
|
740
|
+
typedef std::bidirectional_iterator_tag iterator_category;
|
741
|
+
#endif
|
742
|
+
|
743
|
+
// Default constructor
|
744
|
+
xml_node_iterator();
|
745
|
+
|
746
|
+
// Construct an iterator which points to the specified node
|
747
|
+
xml_node_iterator(const xml_node& node);
|
748
|
+
|
749
|
+
// Iterator operators
|
750
|
+
bool operator==(const xml_node_iterator& rhs) const;
|
751
|
+
bool operator!=(const xml_node_iterator& rhs) const;
|
752
|
+
|
753
|
+
xml_node& operator*() const;
|
754
|
+
xml_node* operator->() const;
|
755
|
+
|
756
|
+
const xml_node_iterator& operator++();
|
757
|
+
xml_node_iterator operator++(int);
|
758
|
+
|
759
|
+
const xml_node_iterator& operator--();
|
760
|
+
xml_node_iterator operator--(int);
|
761
|
+
};
|
762
|
+
|
763
|
+
// Attribute iterator (a bidirectional iterator over a collection of xml_attribute)
|
764
|
+
class PUGIXML_CLASS xml_attribute_iterator
|
765
|
+
{
|
766
|
+
friend class xml_node;
|
767
|
+
|
768
|
+
private:
|
769
|
+
mutable xml_attribute _wrap;
|
770
|
+
xml_node _parent;
|
771
|
+
|
772
|
+
xml_attribute_iterator(xml_attribute_struct* ref, xml_node_struct* parent);
|
773
|
+
|
774
|
+
public:
|
775
|
+
// Iterator traits
|
776
|
+
typedef ptrdiff_t difference_type;
|
777
|
+
typedef xml_attribute value_type;
|
778
|
+
typedef xml_attribute* pointer;
|
779
|
+
typedef xml_attribute& reference;
|
780
|
+
|
781
|
+
#ifndef PUGIXML_NO_STL
|
782
|
+
typedef std::bidirectional_iterator_tag iterator_category;
|
783
|
+
#endif
|
784
|
+
|
785
|
+
// Default constructor
|
786
|
+
xml_attribute_iterator();
|
787
|
+
|
788
|
+
// Construct an iterator which points to the specified attribute
|
789
|
+
xml_attribute_iterator(const xml_attribute& attr, const xml_node& parent);
|
790
|
+
|
791
|
+
// Iterator operators
|
792
|
+
bool operator==(const xml_attribute_iterator& rhs) const;
|
793
|
+
bool operator!=(const xml_attribute_iterator& rhs) const;
|
794
|
+
|
795
|
+
xml_attribute& operator*() const;
|
796
|
+
xml_attribute* operator->() const;
|
797
|
+
|
798
|
+
const xml_attribute_iterator& operator++();
|
799
|
+
xml_attribute_iterator operator++(int);
|
800
|
+
|
801
|
+
const xml_attribute_iterator& operator--();
|
802
|
+
xml_attribute_iterator operator--(int);
|
803
|
+
};
|
804
|
+
|
805
|
+
// Named node range helper
|
806
|
+
class PUGIXML_CLASS xml_named_node_iterator
|
807
|
+
{
|
808
|
+
friend class xml_node;
|
809
|
+
|
810
|
+
public:
|
811
|
+
// Iterator traits
|
812
|
+
typedef ptrdiff_t difference_type;
|
813
|
+
typedef xml_node value_type;
|
814
|
+
typedef xml_node* pointer;
|
815
|
+
typedef xml_node& reference;
|
816
|
+
|
817
|
+
#ifndef PUGIXML_NO_STL
|
818
|
+
typedef std::bidirectional_iterator_tag iterator_category;
|
819
|
+
#endif
|
820
|
+
|
821
|
+
// Default constructor
|
822
|
+
xml_named_node_iterator();
|
823
|
+
|
824
|
+
// Construct an iterator which points to the specified node
|
825
|
+
xml_named_node_iterator(const xml_node& node, const char_t* name);
|
826
|
+
|
827
|
+
// Iterator operators
|
828
|
+
bool operator==(const xml_named_node_iterator& rhs) const;
|
829
|
+
bool operator!=(const xml_named_node_iterator& rhs) const;
|
830
|
+
|
831
|
+
xml_node& operator*() const;
|
832
|
+
xml_node* operator->() const;
|
833
|
+
|
834
|
+
const xml_named_node_iterator& operator++();
|
835
|
+
xml_named_node_iterator operator++(int);
|
836
|
+
|
837
|
+
const xml_named_node_iterator& operator--();
|
838
|
+
xml_named_node_iterator operator--(int);
|
839
|
+
|
840
|
+
private:
|
841
|
+
mutable xml_node _wrap;
|
842
|
+
xml_node _parent;
|
843
|
+
const char_t* _name;
|
844
|
+
|
845
|
+
xml_named_node_iterator(xml_node_struct* ref, xml_node_struct* parent, const char_t* name);
|
846
|
+
};
|
847
|
+
|
848
|
+
// Abstract tree walker class (see xml_node::traverse)
|
849
|
+
class PUGIXML_CLASS xml_tree_walker
|
850
|
+
{
|
851
|
+
friend class xml_node;
|
852
|
+
|
853
|
+
private:
|
854
|
+
int _depth;
|
855
|
+
|
856
|
+
protected:
|
857
|
+
// Get current traversal depth
|
858
|
+
int depth() const;
|
859
|
+
|
860
|
+
public:
|
861
|
+
xml_tree_walker();
|
862
|
+
virtual ~xml_tree_walker();
|
863
|
+
|
864
|
+
// Callback that is called when traversal begins
|
865
|
+
virtual bool begin(xml_node& node);
|
866
|
+
|
867
|
+
// Callback that is called for each node traversed
|
868
|
+
virtual bool for_each(xml_node& node) = 0;
|
869
|
+
|
870
|
+
// Callback that is called when traversal ends
|
871
|
+
virtual bool end(xml_node& node);
|
872
|
+
};
|
873
|
+
|
874
|
+
// Parsing status, returned as part of xml_parse_result object
|
875
|
+
enum xml_parse_status
|
876
|
+
{
|
877
|
+
status_ok = 0, // No error
|
878
|
+
|
879
|
+
status_file_not_found, // File was not found during load_file()
|
880
|
+
status_io_error, // Error reading from file/stream
|
881
|
+
status_out_of_memory, // Could not allocate memory
|
882
|
+
status_internal_error, // Internal error occurred
|
883
|
+
|
884
|
+
status_unrecognized_tag, // Parser could not determine tag type
|
885
|
+
|
886
|
+
status_bad_pi, // Parsing error occurred while parsing document declaration/processing instruction
|
887
|
+
status_bad_comment, // Parsing error occurred while parsing comment
|
888
|
+
status_bad_cdata, // Parsing error occurred while parsing CDATA section
|
889
|
+
status_bad_doctype, // Parsing error occurred while parsing document type declaration
|
890
|
+
status_bad_pcdata, // Parsing error occurred while parsing PCDATA section
|
891
|
+
status_bad_start_element, // Parsing error occurred while parsing start element tag
|
892
|
+
status_bad_attribute, // Parsing error occurred while parsing element attribute
|
893
|
+
status_bad_end_element, // Parsing error occurred while parsing end element tag
|
894
|
+
status_end_element_mismatch,// There was a mismatch of start-end tags (closing tag had incorrect name, some tag was not closed or there was an excessive closing tag)
|
895
|
+
|
896
|
+
status_append_invalid_root, // Unable to append nodes since root type is not node_element or node_document (exclusive to xml_node::append_buffer)
|
897
|
+
|
898
|
+
status_no_document_element // Parsing resulted in a document without element nodes
|
899
|
+
};
|
900
|
+
|
901
|
+
// Parsing result
|
902
|
+
struct PUGIXML_CLASS xml_parse_result
|
903
|
+
{
|
904
|
+
// Parsing status (see xml_parse_status)
|
905
|
+
xml_parse_status status;
|
906
|
+
|
907
|
+
// Last parsed offset (in char_t units from start of input data)
|
908
|
+
ptrdiff_t offset;
|
909
|
+
|
910
|
+
// Source document encoding
|
911
|
+
xml_encoding encoding;
|
912
|
+
|
913
|
+
// Default constructor, initializes object to failed state
|
914
|
+
xml_parse_result();
|
915
|
+
|
916
|
+
// Cast to bool operator
|
917
|
+
operator bool() const;
|
918
|
+
|
919
|
+
// Get error description
|
920
|
+
const char* description() const;
|
921
|
+
};
|
922
|
+
|
923
|
+
// Document class (DOM tree root)
|
924
|
+
class PUGIXML_CLASS xml_document: public xml_node
|
925
|
+
{
|
926
|
+
private:
|
927
|
+
char_t* _buffer;
|
928
|
+
|
929
|
+
char _memory[192];
|
930
|
+
|
931
|
+
// Non-copyable semantics
|
932
|
+
xml_document(const xml_document&);
|
933
|
+
const xml_document& operator=(const xml_document&);
|
934
|
+
|
935
|
+
void create();
|
936
|
+
void destroy();
|
937
|
+
|
938
|
+
public:
|
939
|
+
// Default constructor, makes empty document
|
940
|
+
xml_document();
|
941
|
+
|
942
|
+
// Destructor, invalidates all node/attribute handles to this document
|
943
|
+
~xml_document();
|
944
|
+
|
945
|
+
// Removes all nodes, leaving the empty document
|
946
|
+
void reset();
|
947
|
+
|
948
|
+
// Removes all nodes, then copies the entire contents of the specified document
|
949
|
+
void reset(const xml_document& proto);
|
950
|
+
|
951
|
+
#ifndef PUGIXML_NO_STL
|
952
|
+
// Load document from stream.
|
953
|
+
xml_parse_result load(std::basic_istream<char, std::char_traits<char> >& stream, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
|
954
|
+
xml_parse_result load(std::basic_istream<wchar_t, std::char_traits<wchar_t> >& stream, unsigned int options = parse_default);
|
955
|
+
#endif
|
956
|
+
|
957
|
+
// Load document from zero-terminated string. No encoding conversions are applied.
|
958
|
+
xml_parse_result load(const char_t* contents, unsigned int options = parse_default);
|
959
|
+
|
960
|
+
// Load document from file
|
961
|
+
xml_parse_result load_file(const char* path, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
|
962
|
+
xml_parse_result load_file(const wchar_t* path, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
|
963
|
+
|
964
|
+
// Load document from buffer. Copies/converts the buffer, so it may be deleted or changed after the function returns.
|
965
|
+
xml_parse_result load_buffer(const void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
|
966
|
+
|
967
|
+
// Load document from buffer, using the buffer for in-place parsing (the buffer is modified and used for storage of document data).
|
968
|
+
// You should ensure that buffer data will persist throughout the document's lifetime, and free the buffer memory manually once document is destroyed.
|
969
|
+
xml_parse_result load_buffer_inplace(void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
|
970
|
+
|
971
|
+
// Load document from buffer, using the buffer for in-place parsing (the buffer is modified and used for storage of document data).
|
972
|
+
// You should allocate the buffer with pugixml allocation function; document will free the buffer when it is no longer needed (you can't use it anymore).
|
973
|
+
xml_parse_result load_buffer_inplace_own(void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
|
974
|
+
|
975
|
+
// Save XML document to writer (semantics is slightly different from xml_node::print, see documentation for details).
|
976
|
+
void save(xml_writer& writer, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const;
|
977
|
+
|
978
|
+
#ifndef PUGIXML_NO_STL
|
979
|
+
// Save XML document to stream (semantics is slightly different from xml_node::print, see documentation for details).
|
980
|
+
void save(std::basic_ostream<char, std::char_traits<char> >& stream, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const;
|
981
|
+
void save(std::basic_ostream<wchar_t, std::char_traits<wchar_t> >& stream, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default) const;
|
982
|
+
#endif
|
983
|
+
|
984
|
+
// Save XML to file
|
985
|
+
bool save_file(const char* path, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const;
|
986
|
+
bool save_file(const wchar_t* path, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const;
|
987
|
+
|
988
|
+
// Get document element
|
989
|
+
xml_node document_element() const;
|
990
|
+
};
|
991
|
+
|
992
|
+
#ifndef PUGIXML_NO_XPATH
|
993
|
+
// XPath query return type
|
994
|
+
enum xpath_value_type
|
995
|
+
{
|
996
|
+
xpath_type_none, // Unknown type (query failed to compile)
|
997
|
+
xpath_type_node_set, // Node set (xpath_node_set)
|
998
|
+
xpath_type_number, // Number
|
999
|
+
xpath_type_string, // String
|
1000
|
+
xpath_type_boolean // Boolean
|
1001
|
+
};
|
1002
|
+
|
1003
|
+
// XPath parsing result
|
1004
|
+
struct PUGIXML_CLASS xpath_parse_result
|
1005
|
+
{
|
1006
|
+
// Error message (0 if no error)
|
1007
|
+
const char* error;
|
1008
|
+
|
1009
|
+
// Last parsed offset (in char_t units from string start)
|
1010
|
+
ptrdiff_t offset;
|
1011
|
+
|
1012
|
+
// Default constructor, initializes object to failed state
|
1013
|
+
xpath_parse_result();
|
1014
|
+
|
1015
|
+
// Cast to bool operator
|
1016
|
+
operator bool() const;
|
1017
|
+
|
1018
|
+
// Get error description
|
1019
|
+
const char* description() const;
|
1020
|
+
};
|
1021
|
+
|
1022
|
+
// A single XPath variable
|
1023
|
+
class PUGIXML_CLASS xpath_variable
|
1024
|
+
{
|
1025
|
+
friend class xpath_variable_set;
|
1026
|
+
|
1027
|
+
protected:
|
1028
|
+
xpath_value_type _type;
|
1029
|
+
xpath_variable* _next;
|
1030
|
+
|
1031
|
+
xpath_variable();
|
1032
|
+
|
1033
|
+
// Non-copyable semantics
|
1034
|
+
xpath_variable(const xpath_variable&);
|
1035
|
+
xpath_variable& operator=(const xpath_variable&);
|
1036
|
+
|
1037
|
+
public:
|
1038
|
+
// Get variable name
|
1039
|
+
const char_t* name() const;
|
1040
|
+
|
1041
|
+
// Get variable type
|
1042
|
+
xpath_value_type type() const;
|
1043
|
+
|
1044
|
+
// Get variable value; no type conversion is performed, default value (false, NaN, empty string, empty node set) is returned on type mismatch error
|
1045
|
+
bool get_boolean() const;
|
1046
|
+
double get_number() const;
|
1047
|
+
const char_t* get_string() const;
|
1048
|
+
const xpath_node_set& get_node_set() const;
|
1049
|
+
|
1050
|
+
// Set variable value; no type conversion is performed, false is returned on type mismatch error
|
1051
|
+
bool set(bool value);
|
1052
|
+
bool set(double value);
|
1053
|
+
bool set(const char_t* value);
|
1054
|
+
bool set(const xpath_node_set& value);
|
1055
|
+
};
|
1056
|
+
|
1057
|
+
// A set of XPath variables
|
1058
|
+
class PUGIXML_CLASS xpath_variable_set
|
1059
|
+
{
|
1060
|
+
private:
|
1061
|
+
xpath_variable* _data[64];
|
1062
|
+
|
1063
|
+
// Non-copyable semantics
|
1064
|
+
xpath_variable_set(const xpath_variable_set&);
|
1065
|
+
xpath_variable_set& operator=(const xpath_variable_set&);
|
1066
|
+
|
1067
|
+
xpath_variable* find(const char_t* name) const;
|
1068
|
+
|
1069
|
+
public:
|
1070
|
+
// Default constructor/destructor
|
1071
|
+
xpath_variable_set();
|
1072
|
+
~xpath_variable_set();
|
1073
|
+
|
1074
|
+
// Add a new variable or get the existing one, if the types match
|
1075
|
+
xpath_variable* add(const char_t* name, xpath_value_type type);
|
1076
|
+
|
1077
|
+
// Set value of an existing variable; no type conversion is performed, false is returned if there is no such variable or if types mismatch
|
1078
|
+
bool set(const char_t* name, bool value);
|
1079
|
+
bool set(const char_t* name, double value);
|
1080
|
+
bool set(const char_t* name, const char_t* value);
|
1081
|
+
bool set(const char_t* name, const xpath_node_set& value);
|
1082
|
+
|
1083
|
+
// Get existing variable by name
|
1084
|
+
xpath_variable* get(const char_t* name);
|
1085
|
+
const xpath_variable* get(const char_t* name) const;
|
1086
|
+
};
|
1087
|
+
|
1088
|
+
// A compiled XPath query object
|
1089
|
+
class PUGIXML_CLASS xpath_query
|
1090
|
+
{
|
1091
|
+
private:
|
1092
|
+
void* _impl;
|
1093
|
+
xpath_parse_result _result;
|
1094
|
+
|
1095
|
+
typedef void (*unspecified_bool_type)(xpath_query***);
|
1096
|
+
|
1097
|
+
// Non-copyable semantics
|
1098
|
+
xpath_query(const xpath_query&);
|
1099
|
+
xpath_query& operator=(const xpath_query&);
|
1100
|
+
|
1101
|
+
public:
|
1102
|
+
// Construct a compiled object from XPath expression.
|
1103
|
+
// If PUGIXML_NO_EXCEPTIONS is not defined, throws xpath_exception on compilation errors.
|
1104
|
+
explicit xpath_query(const char_t* query, xpath_variable_set* variables = 0);
|
1105
|
+
|
1106
|
+
// Destructor
|
1107
|
+
~xpath_query();
|
1108
|
+
|
1109
|
+
// Get query expression return type
|
1110
|
+
xpath_value_type return_type() const;
|
1111
|
+
|
1112
|
+
// Evaluate expression as boolean value in the specified context; performs type conversion if necessary.
|
1113
|
+
// If PUGIXML_NO_EXCEPTIONS is not defined, throws std::bad_alloc on out of memory errors.
|
1114
|
+
bool evaluate_boolean(const xpath_node& n) const;
|
1115
|
+
|
1116
|
+
// Evaluate expression as double value in the specified context; performs type conversion if necessary.
|
1117
|
+
// If PUGIXML_NO_EXCEPTIONS is not defined, throws std::bad_alloc on out of memory errors.
|
1118
|
+
double evaluate_number(const xpath_node& n) const;
|
1119
|
+
|
1120
|
+
#ifndef PUGIXML_NO_STL
|
1121
|
+
// Evaluate expression as string value in the specified context; performs type conversion if necessary.
|
1122
|
+
// If PUGIXML_NO_EXCEPTIONS is not defined, throws std::bad_alloc on out of memory errors.
|
1123
|
+
string_t evaluate_string(const xpath_node& n) const;
|
1124
|
+
#endif
|
1125
|
+
|
1126
|
+
// Evaluate expression as string value in the specified context; performs type conversion if necessary.
|
1127
|
+
// At most capacity characters are written to the destination buffer, full result size is returned (includes terminating zero).
|
1128
|
+
// If PUGIXML_NO_EXCEPTIONS is not defined, throws std::bad_alloc on out of memory errors.
|
1129
|
+
// If PUGIXML_NO_EXCEPTIONS is defined, returns empty set instead.
|
1130
|
+
size_t evaluate_string(char_t* buffer, size_t capacity, const xpath_node& n) const;
|
1131
|
+
|
1132
|
+
// Evaluate expression as node set in the specified context.
|
1133
|
+
// If PUGIXML_NO_EXCEPTIONS is not defined, throws xpath_exception on type mismatch and std::bad_alloc on out of memory errors.
|
1134
|
+
// If PUGIXML_NO_EXCEPTIONS is defined, returns empty node set instead.
|
1135
|
+
xpath_node_set evaluate_node_set(const xpath_node& n) const;
|
1136
|
+
|
1137
|
+
// Get parsing result (used to get compilation errors in PUGIXML_NO_EXCEPTIONS mode)
|
1138
|
+
const xpath_parse_result& result() const;
|
1139
|
+
|
1140
|
+
// Safe bool conversion operator
|
1141
|
+
operator unspecified_bool_type() const;
|
1142
|
+
|
1143
|
+
// Borland C++ workaround
|
1144
|
+
bool operator!() const;
|
1145
|
+
};
|
1146
|
+
|
1147
|
+
#ifndef PUGIXML_NO_EXCEPTIONS
|
1148
|
+
// XPath exception class
|
1149
|
+
class PUGIXML_CLASS xpath_exception: public std::exception
|
1150
|
+
{
|
1151
|
+
private:
|
1152
|
+
xpath_parse_result _result;
|
1153
|
+
|
1154
|
+
public:
|
1155
|
+
// Construct exception from parse result
|
1156
|
+
explicit xpath_exception(const xpath_parse_result& result);
|
1157
|
+
|
1158
|
+
// Get error message
|
1159
|
+
virtual const char* what() const throw();
|
1160
|
+
|
1161
|
+
// Get parse result
|
1162
|
+
const xpath_parse_result& result() const;
|
1163
|
+
};
|
1164
|
+
#endif
|
1165
|
+
|
1166
|
+
// XPath node class (either xml_node or xml_attribute)
|
1167
|
+
class PUGIXML_CLASS xpath_node
|
1168
|
+
{
|
1169
|
+
private:
|
1170
|
+
xml_node _node;
|
1171
|
+
xml_attribute _attribute;
|
1172
|
+
|
1173
|
+
typedef void (*unspecified_bool_type)(xpath_node***);
|
1174
|
+
|
1175
|
+
public:
|
1176
|
+
// Default constructor; constructs empty XPath node
|
1177
|
+
xpath_node();
|
1178
|
+
|
1179
|
+
// Construct XPath node from XML node/attribute
|
1180
|
+
xpath_node(const xml_node& node);
|
1181
|
+
xpath_node(const xml_attribute& attribute, const xml_node& parent);
|
1182
|
+
|
1183
|
+
// Get node/attribute, if any
|
1184
|
+
xml_node node() const;
|
1185
|
+
xml_attribute attribute() const;
|
1186
|
+
|
1187
|
+
// Get parent of contained node/attribute
|
1188
|
+
xml_node parent() const;
|
1189
|
+
|
1190
|
+
// Safe bool conversion operator
|
1191
|
+
operator unspecified_bool_type() const;
|
1192
|
+
|
1193
|
+
// Borland C++ workaround
|
1194
|
+
bool operator!() const;
|
1195
|
+
|
1196
|
+
// Comparison operators
|
1197
|
+
bool operator==(const xpath_node& n) const;
|
1198
|
+
bool operator!=(const xpath_node& n) const;
|
1199
|
+
};
|
1200
|
+
|
1201
|
+
#ifdef __BORLANDC__
|
1202
|
+
// Borland C++ workaround
|
1203
|
+
bool PUGIXML_FUNCTION operator&&(const xpath_node& lhs, bool rhs);
|
1204
|
+
bool PUGIXML_FUNCTION operator||(const xpath_node& lhs, bool rhs);
|
1205
|
+
#endif
|
1206
|
+
|
1207
|
+
// A fixed-size collection of XPath nodes
|
1208
|
+
class PUGIXML_CLASS xpath_node_set
|
1209
|
+
{
|
1210
|
+
public:
|
1211
|
+
// Collection type
|
1212
|
+
enum type_t
|
1213
|
+
{
|
1214
|
+
type_unsorted, // Not ordered
|
1215
|
+
type_sorted, // Sorted by document order (ascending)
|
1216
|
+
type_sorted_reverse // Sorted by document order (descending)
|
1217
|
+
};
|
1218
|
+
|
1219
|
+
// Constant iterator type
|
1220
|
+
typedef const xpath_node* const_iterator;
|
1221
|
+
|
1222
|
+
// We define non-constant iterator to be the same as constant iterator so that various generic algorithms (i.e. boost foreach) work
|
1223
|
+
typedef const xpath_node* iterator;
|
1224
|
+
|
1225
|
+
// Default constructor. Constructs empty set.
|
1226
|
+
xpath_node_set();
|
1227
|
+
|
1228
|
+
// Constructs a set from iterator range; data is not checked for duplicates and is not sorted according to provided type, so be careful
|
1229
|
+
xpath_node_set(const_iterator begin, const_iterator end, type_t type = type_unsorted);
|
1230
|
+
|
1231
|
+
// Destructor
|
1232
|
+
~xpath_node_set();
|
1233
|
+
|
1234
|
+
// Copy constructor/assignment operator
|
1235
|
+
xpath_node_set(const xpath_node_set& ns);
|
1236
|
+
xpath_node_set& operator=(const xpath_node_set& ns);
|
1237
|
+
|
1238
|
+
// Get collection type
|
1239
|
+
type_t type() const;
|
1240
|
+
|
1241
|
+
// Get collection size
|
1242
|
+
size_t size() const;
|
1243
|
+
|
1244
|
+
// Indexing operator
|
1245
|
+
const xpath_node& operator[](size_t index) const;
|
1246
|
+
|
1247
|
+
// Collection iterators
|
1248
|
+
const_iterator begin() const;
|
1249
|
+
const_iterator end() const;
|
1250
|
+
|
1251
|
+
// Sort the collection in ascending/descending order by document order
|
1252
|
+
void sort(bool reverse = false);
|
1253
|
+
|
1254
|
+
// Get first node in the collection by document order
|
1255
|
+
xpath_node first() const;
|
1256
|
+
|
1257
|
+
// Check if collection is empty
|
1258
|
+
bool empty() const;
|
1259
|
+
|
1260
|
+
private:
|
1261
|
+
type_t _type;
|
1262
|
+
|
1263
|
+
xpath_node _storage;
|
1264
|
+
|
1265
|
+
xpath_node* _begin;
|
1266
|
+
xpath_node* _end;
|
1267
|
+
|
1268
|
+
void _assign(const_iterator begin, const_iterator end);
|
1269
|
+
};
|
1270
|
+
#endif
|
1271
|
+
|
1272
|
+
#ifndef PUGIXML_NO_STL
|
1273
|
+
// Convert wide string to UTF8
|
1274
|
+
std::basic_string<char, std::char_traits<char>, std::allocator<char> > PUGIXML_FUNCTION as_utf8(const wchar_t* str);
|
1275
|
+
std::basic_string<char, std::char_traits<char>, std::allocator<char> > PUGIXML_FUNCTION as_utf8(const std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >& str);
|
1276
|
+
|
1277
|
+
// Convert UTF8 to wide string
|
1278
|
+
std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > PUGIXML_FUNCTION as_wide(const char* str);
|
1279
|
+
std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > PUGIXML_FUNCTION as_wide(const std::basic_string<char, std::char_traits<char>, std::allocator<char> >& str);
|
1280
|
+
#endif
|
1281
|
+
|
1282
|
+
// Memory allocation function interface; returns pointer to allocated memory or NULL on failure
|
1283
|
+
typedef void* (*allocation_function)(size_t size);
|
1284
|
+
|
1285
|
+
// Memory deallocation function interface
|
1286
|
+
typedef void (*deallocation_function)(void* ptr);
|
1287
|
+
|
1288
|
+
// Override default memory management functions. All subsequent allocations/deallocations will be performed via supplied functions.
|
1289
|
+
void PUGIXML_FUNCTION set_memory_management_functions(allocation_function allocate, deallocation_function deallocate);
|
1290
|
+
|
1291
|
+
// Get current memory management functions
|
1292
|
+
allocation_function PUGIXML_FUNCTION get_memory_allocation_function();
|
1293
|
+
deallocation_function PUGIXML_FUNCTION get_memory_deallocation_function();
|
1294
|
+
}
|
1295
|
+
|
1296
|
+
#if !defined(PUGIXML_NO_STL) && (defined(_MSC_VER) || defined(__ICC))
|
1297
|
+
namespace std
|
1298
|
+
{
|
1299
|
+
// Workarounds for (non-standard) iterator category detection for older versions (MSVC7/IC8 and earlier)
|
1300
|
+
std::bidirectional_iterator_tag PUGIXML_FUNCTION _Iter_cat(const pugi::xml_node_iterator&);
|
1301
|
+
std::bidirectional_iterator_tag PUGIXML_FUNCTION _Iter_cat(const pugi::xml_attribute_iterator&);
|
1302
|
+
std::bidirectional_iterator_tag PUGIXML_FUNCTION _Iter_cat(const pugi::xml_named_node_iterator&);
|
1303
|
+
}
|
1304
|
+
#endif
|
1305
|
+
|
1306
|
+
#if !defined(PUGIXML_NO_STL) && defined(__SUNPRO_CC)
|
1307
|
+
namespace std
|
1308
|
+
{
|
1309
|
+
// Workarounds for (non-standard) iterator category detection
|
1310
|
+
std::bidirectional_iterator_tag PUGIXML_FUNCTION __iterator_category(const pugi::xml_node_iterator&);
|
1311
|
+
std::bidirectional_iterator_tag PUGIXML_FUNCTION __iterator_category(const pugi::xml_attribute_iterator&);
|
1312
|
+
std::bidirectional_iterator_tag PUGIXML_FUNCTION __iterator_category(const pugi::xml_named_node_iterator&);
|
1313
|
+
}
|
1314
|
+
#endif
|
1315
|
+
|
1316
|
+
#endif
|
1317
|
+
|
1318
|
+
/**
|
1319
|
+
* Copyright (c) 2006-2014 Arseny Kapoulkine
|
1320
|
+
*
|
1321
|
+
* Permission is hereby granted, free of charge, to any person
|
1322
|
+
* obtaining a copy of this software and associated documentation
|
1323
|
+
* files (the "Software"), to deal in the Software without
|
1324
|
+
* restriction, including without limitation the rights to use,
|
1325
|
+
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
1326
|
+
* copies of the Software, and to permit persons to whom the
|
1327
|
+
* Software is furnished to do so, subject to the following
|
1328
|
+
* conditions:
|
1329
|
+
*
|
1330
|
+
* The above copyright notice and this permission notice shall be
|
1331
|
+
* included in all copies or substantial portions of the Software.
|
1332
|
+
*
|
1333
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
1334
|
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
1335
|
+
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
1336
|
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
1337
|
+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
1338
|
+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
1339
|
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
1340
|
+
* OTHER DEALINGS IN THE SOFTWARE.
|
1341
|
+
*/
|