neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
xml.hpp
Go to the documentation of this file.
1// xml.hpp
2/*
3 * NoFussXML v5.3.3
4 *
5 * Copyright (c) 2007 Leigh Johnston.
6 *
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are
11 * met:
12 *
13 * * Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 *
16 * * Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 *
20 * * Neither the name of Leigh Johnston nor the names of any
21 * other contributors to this software may be used to endorse or
22 * promote products derived from this software without specific prior
23 * written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
26 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
27 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
29 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36*/
37
38#pragma once
39
40#include <neolib/neolib.hpp>
41#include <cstddef>
42#include <istream>
43#include <ostream>
44#include <list>
45#include <map>
46#include <utility>
47#include <string>
48#include <memory>
49#include <exception>
52
53#define NEOLIB_XML_USE_POOL_ALLOCATOR
54
55namespace neolib
56{
57 template <typename CharT, typename Alloc = std::allocator<CharT> >
59 {
60 public:
61 // types
62 enum type_e { Document = 0x1, Element = 0x2, Text = 0x4, Comment = 0x8, Declaration = 0x10, Cdata = 0x20, Dtd = 0x40, All = 0xFF };
63 typedef Alloc allocator_type;
66 typedef node* node_ptr;
67 private:
68 // types
69 typedef std::list<node_ptr, typename std::allocator_traits<allocator_type>::template rebind_alloc<node_ptr>> node_list;
70 /* Why std::list of pointers instead of std::vector of pointers? std::vector is not compatible with chunk allocator
71 and timings indicate performance benefit of std::list with chunk allocator compared to std::vector when parsing large (~10MB) XML files. */
72 public:
73 // types
74 class const_iterator;
76 {
77 friend class const_iterator;
78 public:
79 iterator() : iNode(0), iIterator(), iFilter(node::All) {}
80 iterator(node& aNode, typename node::node_list::iterator aIterator, typename node::type_e aFilter = node::All) : iNode(&aNode), iIterator(aIterator), iFilter(aFilter) {}
81 iterator(const iterator& aOther) : iNode(aOther.iNode), iIterator(aOther.iIterator), iFilter(aOther.iFilter) {}
82 iterator& operator=(const iterator& aOther) { iNode = aOther.iNode; iIterator = aOther.iIterator; iFilter = aOther.iFilter; return *this; }
83 public:
84 node& operator*() const { return static_cast<node&>(**iIterator); }
85 node* operator->() const { return static_cast<node*>(&**iIterator); }
87 {
88 ++iIterator;
89 iterator endIterator = iNode->end(iFilter);
90 while (*this != endIterator && !((*iIterator)->type() & iFilter))
91 ++iIterator;
92 return *this;
93 }
95 {
96 --iIterator;
97 iterator beginIterator = iNode->begin(iFilter);
98 while (*this != beginIterator && !((*iIterator)->type() & iFilter))
99 --iIterator;
100 return *this;
101 }
102 iterator operator++(int) { iterator temp(*this); operator++(); return temp; }
103 iterator operator--(int) { iterator temp(*this); operator--(); return temp; }
104 bool operator==(const iterator& aOther) const { return iIterator == aOther.iIterator; }
105 bool operator!=(const iterator& aOther) const { return !(*this == aOther); }
106 typename node::node_list::iterator base() const { return iIterator; }
107 private:
108 node* iNode;
109 typename node::node_list::iterator iIterator;
110 typename node::type_e iFilter;
111 };
113 {
114 public:
115 const_iterator() : iNode(0), iIterator(), iFilter(node::All) {}
116 const_iterator(const node& aNode, typename node::node_list::const_iterator aIterator, typename node::type_e aFilter = node::All) : iNode(&aNode), iIterator(aIterator), iFilter(aFilter) {}
117 const_iterator(const const_iterator& aOther) : iNode(aOther.iNode), iIterator(aOther.iIterator), iFilter(aOther.iFilter) {}
118 const_iterator(const iterator aIterator) : iNode(aIterator.iNode), iIterator(typename node::node_list::const_iterator(aIterator.iIterator)), iFilter(aIterator.iFilter) {}
119 const_iterator& operator=(const const_iterator& aOther) { iNode = aOther.iNode; iIterator = aOther.iIterator; iFilter = aOther.iFilter; return *this; }
120 const_iterator& operator=(const iterator& aOther) { iNode = aOther.iNode; iIterator = aOther.iIterator; iFilter = aOther.iFilter; return *this; }
121 public:
122 const node& operator*() const { return static_cast<const node&>(**iIterator); }
123 const node* operator->() const { return static_cast<const node*>(&**iIterator); }
125 {
126 ++iIterator;
127 const_iterator endIterator = iNode->end(iFilter);
128 while (*this != endIterator && !((*iIterator)->type() & iFilter))
129 ++iIterator;
130 return *this;
131 }
133 {
134 --iIterator;
135 const_iterator beginIterator = iNode->begin(iFilter);
136 while (*this != beginIterator && !((*iIterator)->type() & iFilter))
137 --iIterator;
138 return *this;
139 }
140 const_iterator operator++(int) { const_iterator temp(*this); operator++(); return temp; }
141 const_iterator operator--(int) { const_iterator temp(*this); operator--(); return temp; }
142 bool operator==(const const_iterator& aOther) const { return iIterator == aOther.iIterator; }
143 bool operator!=(const const_iterator& aOther) const { return !(*this == aOther); }
144 typename node::node_list::const_iterator base() const { return iIterator; }
145 private:
146 const node* iNode;
147 typename node::node_list::const_iterator iIterator;
148 typename node::type_e iFilter;
149 };
150
151 public:
152 // construction
153 xml_node(type_e aType = Document) : iType(aType) {}
154 virtual ~xml_node() { clear(); }
155
156 public:
157 // operations
158 type_e type() const { return iType; }
159 // access
160 bool empty() const { return iContent.empty(); }
161 const node& back() const { return *iContent.back(); }
162 node& back() { return *iContent.back(); }
163 const_iterator begin(type_e aFilter = All) const;
164 const_iterator end(type_e aFilter = All) const;
165 iterator begin(type_e aFilter = All);
166 iterator end(type_e aFilter = All);
167 const_iterator find(const string& aName) const;
168 std::optional<const_iterator> find_maybe(const string& aName) const;
169 template <typename Exception>
170 const_iterator find_or_throw(const string& aName) const;
171 iterator find(const string& aName);
172 std::optional<iterator> find_maybe(const string& aName);
173 iterator find_or_append(const string& aName);
174 template <typename Exception>
175 iterator find_or_throw(const string& aName);
176 // modifiers
177 void push_back(node_ptr aNode)
178 {
179 std::unique_ptr<node> newNode(aNode);
180 iContent.push_back(0);
181 iContent.back() = newNode.release();
182 }
184 {
185 std::unique_ptr<node> newNode(aNode);
186 typename node_list::iterator i = iContent.insert(aIterator.base(), 0);
187 *i = newNode.release();
188 return iterator(*this, i);
189 }
190 void erase(iterator aIterator)
191 {
192 delete *aIterator.base();
193 iContent.erase(aIterator.base());
194 }
195 void clear()
196 {
197 for (typename node_list::iterator i = iContent.begin(); i != iContent.end(); ++i)
198 delete *i;
199 iContent.clear();
200 }
201
202 private:
203 // implementation
204 const node_list& content() const { return iContent; }
205 node_list& content() { return iContent; }
206 xml_node(const xml_node&); // not allowed
207 xml_node& operator=(const xml_node&); // not allowed
208
209 private:
210 // attributes
211 type_e iType;
212 node_list iContent;
213 };
214
215 template <typename CharT, typename Alloc = std::allocator<CharT> >
216 class xml_element : public xml_node<CharT, Alloc>
217 {
218 public:
219 // allocation
220 static void* operator new(std::size_t) { return typename std::allocator_traits<Alloc>::template rebind_alloc<xml_element>().allocate(1); }
221 static void operator delete(void* ptr) { return typename std::allocator_traits<Alloc>::template rebind_alloc<xml_element>().deallocate(static_cast<xml_element*>(ptr), 1); }
222
223 public:
224 // types
227 typedef typename node::string string;
228 typedef std::pair<const string, string> attribute;
229 typedef std::map<string, string, std::less<string>, typename std::allocator_traits<allocator_type>::template rebind_alloc<attribute>> attribute_list;
231 {
232 public:
233 iterator(typename node::iterator aIterator) : node::iterator(aIterator) {}
234 xml_element& operator*() const { return static_cast<xml_element&>(node::iterator::operator*()); }
235 xml_element* operator->() const { return static_cast<xml_element*>(node::iterator::operator->()); }
236 };
238 {
239 public:
240 const_iterator(typename node::const_iterator aIterator) : node::const_iterator(aIterator) {}
241 const_iterator(const iterator& aIterator) : node::const_iterator(aIterator) {}
242 const xml_element& operator*() const { return static_cast<const xml_element&>(node::const_iterator::operator*()); }
243 const xml_element* operator->() const { return static_cast<const xml_element*>(node::const_iterator::operator->()); }
244 };
245
246 public:
247 // construction
248 xml_element() : node(node::Element), iUseEmptyElementTag(true) {}
249 xml_element(const string& aName) : node(node::Element), iName(aName), iUseEmptyElementTag(true) {}
250 xml_element(const CharT* aName) : node(node::Element), iName(aName), iUseEmptyElementTag(true) {}
251
252 public:
253 // operations
254 const string& name() const { return iName; }
255 using node::insert;
256 typename node::iterator insert(typename node::iterator aPosition, const CharT* aName) { return node::insert(aPosition, new xml_element(aName)); }
257 xml_element& append(const std::string& aName) { node::push_back(new xml_element(aName)); return static_cast<xml_element&>(node::back()); }
258 xml_element& append(const CharT* aName) { node::push_back(new xml_element(aName)); return static_cast<xml_element&>(node::back()); }
259 const attribute_list& attributes() const { return iAttributes; }
260 bool has_attribute(const string& aAttributeName) const;
261 const string& attribute_value(const string& aAttributeName) const;
262 const string& attribute_value(const string& aNewAttributeName, const string& aOldAttributeName) const;
267 const string& text() const;
268 bool use_empty_element_tag() const { return iUseEmptyElementTag; }
269 string& name() { return iName; }
270 attribute_list& attributes() { return iAttributes; }
271 void set_attribute(const string& aAttributeName, const string& aAttributeValue);
272 void append_text(const string& aText);
273 void set_use_empty_element_tag(bool aUseEmptyElementTag) { iUseEmptyElementTag = aUseEmptyElementTag; }
274
275 private:
276 // attributes
277 string iName;
278 attribute_list iAttributes;
279 mutable string iText;
280 bool iUseEmptyElementTag;
281 };
282
283 template <typename CharT, typename Alloc = std::allocator<CharT> >
284 class xml_text : public xml_node<CharT, Alloc>
285 {
286 public:
287 // allocation
288 static void* operator new(std::size_t) { return typename std::allocator_traits<Alloc>::template rebind_alloc<xml_text>().allocate(1); }
289 static void operator delete(void* ptr) { return typename std::allocator_traits<Alloc>::template rebind_alloc<xml_text>().deallocate(static_cast<xml_text*>(ptr), 1); }
290
291 public:
292 // types
294 typedef typename node::string string;
295
296 public:
297 // construction
298 xml_text(const string& aContent = string()) : node(node::Text), iContent(aContent) {}
299
300 public:
301 // operations
302 const string& content() const { return iContent; }
303 string& content() { return iContent; }
304
305 private:
306 // attributes
307 string iContent;
308 };
309
310 template <typename CharT, typename Alloc = std::allocator<CharT> >
311 class xml_comment : public xml_node<CharT, Alloc>
312 {
313 public:
314 // allocation
315 static void* operator new(std::size_t) { return typename std::allocator_traits<Alloc>::template rebind_alloc<xml_comment>().allocate(1); }
316 static void operator delete(void* ptr) { return typename std::allocator_traits<Alloc>::template rebind_alloc<xml_comment>().deallocate(static_cast<xml_comment*>(ptr), 1); }
317
318 public:
319 // types
321 typedef typename node::string string;
322
323 public:
324 // construction
325 xml_comment(const string& aContent = string()) : node(node::Comment), iContent(aContent) {}
326
327 public:
328 // operations
329 const string& content() const { return iContent; }
330 string& content() { return iContent; }
331
332 private:
333 // attributes
334 string iContent;
335 };
336
337 template <typename CharT, typename Alloc = std::allocator<CharT> >
338 class xml_declaration : public xml_node<CharT, Alloc>
339 {
340 public:
341 // allocation
342 static void* operator new(std::size_t) { return typename std::allocator_traits<Alloc>::template rebind_alloc<xml_declaration>().allocate(1); }
343 static void operator delete(void* ptr) { return typename std::allocator_traits<Alloc>::template rebind_alloc<xml_declaration>().deallocate(static_cast<xml_declaration*>(ptr), 1); }
344
345 public:
346 // types
348 typedef typename node::string string;
349
350 public:
351 // construction
352 xml_declaration(const string& aContent = string()) : node(node::Declaration), iContent(aContent) {}
353
354 public:
355 // operations
356 const string& content() const { return iContent; }
357 string& content() { return iContent; }
358
359 private:
360 // attributes
361 string iContent;
362 };
363
364 template <typename CharT, typename Alloc = std::allocator<CharT> >
365 class xml_cdata : public xml_node<CharT, Alloc>
366 {
367 public:
368 // allocation
369 static void* operator new(std::size_t) { return typename std::allocator_traits<Alloc>::template rebind_alloc<xml_cdata>().allocate(1); }
370 static void operator delete(void* ptr) { return typename std::allocator_traits<Alloc>::template rebind_alloc<xml_cdata>().deallocate(static_cast<xml_cdata*>(ptr), 1); }
371
372 public:
373 // types
375 typedef typename node::string string;
376
377 public:
378 // construction
379 xml_cdata(const string& aContent = string()) : node(node::Cdata), iContent(aContent) {}
380
381 public:
382 // operations
383 const string& content() const { return iContent; }
384 string& content() { return iContent; }
385
386 private:
387 // attributes
388 string iContent;
389 };
390
391 template <typename CharT, typename Alloc = std::allocator<CharT> >
392 class xml_dtd : public xml_node<CharT, Alloc>
393 {
394 public:
395 // allocation
396 static void* operator new(std::size_t) { return typename std::allocator_traits<Alloc>::template rebind_alloc<xml_dtd>().allocate(1); }
397 static void operator delete(void* ptr) { return typename std::allocator_traits<Alloc>::template rebind_alloc<xml_dtd>().deallocate(static_cast<xml_dtd*>(ptr), 1); }
398
399 public:
400 // types
402 typedef typename node::string string;
403
404 public:
405 // construction
406 xml_dtd(const string& aContent = string()) : node(node::Dtd), iContent(aContent) {}
407
408 public:
409 // operations
410 const string& content() const { return iContent; }
411 string& content() { return iContent; }
412
413 private:
414 // attributes
415 string iContent;
416 };
417
418 template <typename CharT, typename Alloc = std::allocator<CharT> >
420 {
421 // types
422 public:
423 typedef Alloc allocator_type;
425 typedef typename node::string string;
426 typedef typename node::node_ptr node_ptr;
428 typedef typename element::attribute attribute;
429 typedef typename element::attribute_list attribute_list;
435 typedef std::pair<string, string> entity;
436 typedef std::list<entity, typename std::allocator_traits<allocator_type>::template rebind_alloc<entity>> entity_list;
437
438 // exceptions
439 public:
440 struct error_no_root : std::runtime_error { error_no_root() : std::runtime_error("neolib::basic_xml::error_no_root") {} };
441 struct failed_to_open_file : std::runtime_error { failed_to_open_file() : std::runtime_error("neolib::basic_xml::failed_to_open_file") {} };
442
443 // construction
444 public:
445 basic_xml(bool aStripWhitespace = false);
446 basic_xml(const std::string& aPath, bool aStripWhitespace = false);
447
448 // operations
449 public:
450 void clear();
451 const node& document() const;
452 node& document();
453 const element& root() const;
454 element& root();
455 bool got_root() const;
456 typename node::iterator insert(node& aParent, typename node::iterator aPosition, const CharT* aName);
457 element& append(node& aParent, const CharT* aName);
458 void erase(node& aParent, typename node::iterator aPosition);
459 typename node::const_iterator find(const node& aParent, const CharT* aName) const;
460 typename node::iterator find(node& aParent, const CharT* aName);
461 typename node::iterator find_or_append(node& aParent, const CharT* aName);
462 bool read(std::basic_istream<CharT>& aStream);
463 bool write(std::basic_ostream<CharT>& aStream);
464 bool error() const { return iError; }
465 void set_indent(CharT aIndentChar, std::size_t aIndentCount = 1);
466 void set_strip_whitespace(bool aStripWhitespace);
467
468 // implementation
469 private:
470 struct tag : std::pair<typename string::view_const_iterator, typename string::view_const_iterator>
471 {
472 typename node::type_e iType;
473 tag() : iType(node::Element) {}
474 typename node::type_e type() const { return iType; }
475 typename string::size_type end_skip() const
476 {
477 switch(iType)
478 {
479 case node::Element:
480 return 1;
481 case node::Comment:
482 return basic_xml<CharT, Alloc>::sCommentEnd.size();
484 return basic_xml<CharT, Alloc>::sDeclarationEnd.size();
485 case node::Cdata:
486 return basic_xml<CharT, Alloc>::sCdataEnd.size();
487 case node::Dtd:
488 return basic_xml<CharT, Alloc>::sDtdEnd.size();
489 default:
490 return 0;
491 }
492 }
493 };
494 struct token : std::pair<typename string::view_const_iterator, typename string::view_const_iterator>
495 {
496 bool iHasEntities;
497 token() : iHasEntities(false) {}
498 };
499 tag next_tag(typename string::view_const_iterator aNext, typename string::view_const_iterator aDocumentEnd);
500 typename string::view_const_iterator parse(node& aNode, const tag& aStartTag, typename string::view_const_iterator aDocumentEnd);
501 struct node_writer
502 {
503 std::basic_ostream<CharT>& iStream;
504 bool iLastWasNewLine;
505 node_writer(std::basic_ostream<CharT>& aStream) : iStream(aStream), iLastWasNewLine(false) {}
506 template <typename T>
507 node_writer& operator<<(const T& aData);
508 node_writer& operator<<(const string& aData);
509 private:
510 node_writer& operator=(const node_writer&); // undefined
511 };
512 void write_node(node_writer& aStream, const node& aNode, std::size_t aIndent) const;
513 string parse_entities(const string& aString) const;
514 string generate_entities(const string& aString) const;
515 void strip(string& aString) const;
516 void strip_if(string& aString) const;
517 token next_token(const basic_character_map<CharT>& aDelimeters, bool aIgnoreWhitespace, typename string::view_const_iterator aCurrent, typename string::view_const_iterator aEnd) const;
518
519 // attributes
520 private:
521 std::basic_ostream<CharT>& (&endl)(std::basic_ostream<CharT>&);
522 mutable bool iError;
523 node iDocument;
524 entity_list iEntities;
525 string iDocumentText;
526 CharT iIndentChar;
527 std::size_t iIndentCount;
528 bool iStripWhitespace;
529
530 static const basic_character_map<CharT> sNameDelimeter;
531 static const basic_character_map<CharT> sNameBadDelimeter;
532 static const basic_character_map<CharT> sAttributeValueDelimeter;
533 static const basic_character_map<CharT> sAttributeValueInvalidOne;
534 static const basic_character_map<CharT> sAttributeValueInvalidTwo;
535 static const basic_character_map<CharT> sTagDelimeter;
536 static const basic_character_map<CharT> sWhitespace;
537 static const string sCommentStart;
538 static const string sCommentEnd;
539 static const string sCdataStart;
540 static const string sCdataEnd;
541 static const string sDtdStart;
542 static const string sDtdEnd;
543 static const string sDeclarationStart;
544 static const string sDeclarationEnd;
545 static const string sEmptyTagWithAttributes;
546 static const string sEmptyTag;
547 };
548
549 #ifndef NEOLIB_XML_USE_POOL_ALLOCATOR
550 typedef basic_xml<char> xml;
551 typedef basic_xml<wchar_t> wxml;
552 #else // NEOLIB_XML_USE_POOL_ALLOCATOR
555 #endif
556}
557
558#include <neolib/file/xml.inl>
const element & root() const
Definition xml.inl:484
std::list< entity, typename std::allocator_traits< allocator_type >::template rebind_alloc< entity > > entity_list
Definition xml.hpp:436
xml_declaration< CharT, allocator_type > declaration
Definition xml.hpp:432
bool error() const
Definition xml.hpp:464
element::attribute_list attribute_list
Definition xml.hpp:429
xml_node< CharT, allocator_type > node
Definition xml.hpp:424
node::node_ptr node_ptr
Definition xml.hpp:426
node::const_iterator find(const node &aParent, const CharT *aName) const
Definition xml.inl:927
bool write(std::basic_ostream< CharT > &aStream)
Definition xml.inl:798
xml_element< CharT, allocator_type > element
Definition xml.hpp:427
std::pair< string, string > entity
Definition xml.hpp:435
node::iterator insert(node &aParent, typename node::iterator aPosition, const CharT *aName)
Definition xml.inl:909
Alloc allocator_type
Definition xml.hpp:423
node::iterator find_or_append(node &aParent, const CharT *aName)
Definition xml.inl:939
void set_strip_whitespace(bool aStripWhitespace)
Definition xml.inl:816
element & append(node &aParent, const CharT *aName)
Definition xml.inl:915
xml_cdata< CharT, allocator_type > cdata
Definition xml.hpp:433
node::string string
Definition xml.hpp:425
bool got_root() const
Definition xml.inl:504
bool read(std::basic_istream< CharT > &aStream)
Definition xml.inl:747
xml_dtd< CharT, allocator_type > dtd
Definition xml.hpp:434
element::attribute attribute
Definition xml.hpp:428
const node & document() const
Definition xml.inl:472
void set_indent(CharT aIndentChar, std::size_t aIndentCount=1)
Definition xml.inl:809
xml_text< CharT, allocator_type > text
Definition xml.hpp:430
xml_comment< CharT, allocator_type > comment
Definition xml.hpp:431
void erase(node &aParent, typename node::iterator aPosition)
Definition xml.inl:921
node::string string
Definition xml.hpp:375
xml_node< CharT, Alloc > node
Definition xml.hpp:374
const string & content() const
Definition xml.hpp:383
string & content()
Definition xml.hpp:384
xml_cdata(const string &aContent=string())
Definition xml.hpp:379
const string & content() const
Definition xml.hpp:329
node::string string
Definition xml.hpp:321
xml_node< CharT, Alloc > node
Definition xml.hpp:320
string & content()
Definition xml.hpp:330
xml_comment(const string &aContent=string())
Definition xml.hpp:325
const string & content() const
Definition xml.hpp:356
node::string string
Definition xml.hpp:348
xml_declaration(const string &aContent=string())
Definition xml.hpp:352
string & content()
Definition xml.hpp:357
xml_node< CharT, Alloc > node
Definition xml.hpp:347
xml_dtd(const string &aContent=string())
Definition xml.hpp:406
const string & content() const
Definition xml.hpp:410
node::string string
Definition xml.hpp:402
string & content()
Definition xml.hpp:411
xml_node< CharT, Alloc > node
Definition xml.hpp:401
const xml_element * operator->() const
Definition xml.hpp:243
const xml_element & operator*() const
Definition xml.hpp:242
const_iterator(const iterator &aIterator)
Definition xml.hpp:241
const_iterator(typename node::const_iterator aIterator)
Definition xml.hpp:240
xml_element * operator->() const
Definition xml.hpp:235
xml_element & operator*() const
Definition xml.hpp:234
iterator(typename node::iterator aIterator)
Definition xml.hpp:233
attribute_list & attributes()
Definition xml.hpp:270
const string & name() const
Definition xml.hpp:254
node::string string
Definition xml.hpp:227
xml_element(const CharT *aName)
Definition xml.hpp:250
node::allocator_type allocator_type
Definition xml.hpp:226
xml_element & append(const CharT *aName)
Definition xml.hpp:258
xml_element(const string &aName)
Definition xml.hpp:249
iterator begin()
Definition xml.hpp:265
xml_element & append(const std::string &aName)
Definition xml.hpp:257
void set_use_empty_element_tag(bool aUseEmptyElementTag)
Definition xml.hpp:273
node::iterator insert(typename node::iterator aPosition, const CharT *aName)
Definition xml.hpp:256
const string & text() const
Definition xml.inl:402
string & name()
Definition xml.hpp:269
bool has_attribute(const string &aAttributeName) const
Definition xml.inl:377
const_iterator end() const
Definition xml.hpp:264
const attribute_list & attributes() const
Definition xml.hpp:259
xml_node< CharT, Alloc > node
Definition xml.hpp:225
void set_attribute(const string &aAttributeName, const string &aAttributeValue)
Definition xml.inl:412
std::map< string, string, std::less< string >, typename std::allocator_traits< allocator_type >::template rebind_alloc< attribute > > attribute_list
Definition xml.hpp:229
void append_text(const string &aText)
Definition xml.inl:418
bool use_empty_element_tag() const
Definition xml.hpp:268
iterator end()
Definition xml.hpp:266
const string & attribute_value(const string &aAttributeName) const
Definition xml.inl:383
const_iterator begin() const
Definition xml.hpp:263
std::pair< const string, string > attribute
Definition xml.hpp:228
const_iterator & operator=(const const_iterator &aOther)
Definition xml.hpp:119
const_iterator(const iterator aIterator)
Definition xml.hpp:118
const_iterator operator--(int)
Definition xml.hpp:141
const_iterator(const const_iterator &aOther)
Definition xml.hpp:117
const node * operator->() const
Definition xml.hpp:123
const node & operator*() const
Definition xml.hpp:122
const_iterator & operator++()
Definition xml.hpp:124
bool operator==(const const_iterator &aOther) const
Definition xml.hpp:142
bool operator!=(const const_iterator &aOther) const
Definition xml.hpp:143
node::node_list::const_iterator base() const
Definition xml.hpp:144
const_iterator operator++(int)
Definition xml.hpp:140
const_iterator & operator--()
Definition xml.hpp:132
const_iterator & operator=(const iterator &aOther)
Definition xml.hpp:120
const_iterator(const node &aNode, typename node::node_list::const_iterator aIterator, typename node::type_e aFilter=node::All)
Definition xml.hpp:116
node * operator->() const
Definition xml.hpp:85
iterator & operator--()
Definition xml.hpp:94
bool operator!=(const iterator &aOther) const
Definition xml.hpp:105
node & operator*() const
Definition xml.hpp:84
bool operator==(const iterator &aOther) const
Definition xml.hpp:104
iterator operator--(int)
Definition xml.hpp:103
node::node_list::iterator base() const
Definition xml.hpp:106
iterator operator++(int)
Definition xml.hpp:102
iterator(const iterator &aOther)
Definition xml.hpp:81
iterator & operator=(const iterator &aOther)
Definition xml.hpp:82
iterator(node &aNode, typename node::node_list::iterator aIterator, typename node::type_e aFilter=node::All)
Definition xml.hpp:80
iterator & operator++()
Definition xml.hpp:86
iterator find_or_append(const string &aName)
Definition xml.inl:346
const_iterator find_or_throw(const string &aName) const
Definition xml.inl:358
void push_back(node_ptr aNode)
Definition xml.hpp:177
void erase(iterator aIterator)
Definition xml.hpp:190
iterator insert(iterator aIterator, node_ptr aNode)
Definition xml.hpp:183
void clear()
Definition xml.hpp:195
std::optional< const_iterator > find_maybe(const string &aName) const
Definition xml.inl:317
const_iterator find(const string &aName) const
Definition xml.inl:308
Alloc allocator_type
Definition xml.hpp:63
xml_node(type_e aType=Document)
Definition xml.hpp:153
node * node_ptr
Definition xml.hpp:66
type_e type() const
Definition xml.hpp:158
bool empty() const
Definition xml.hpp:160
const_iterator end(type_e aFilter=All) const
Definition xml.inl:287
const node & back() const
Definition xml.hpp:161
const_iterator begin(type_e aFilter=All) const
Definition xml.inl:278
virtual ~xml_node()
Definition xml.hpp:154
xml_node< CharT, allocator_type > node
Definition xml.hpp:65
basic_quick_string< CharT > string
Definition xml.hpp:64
node & back()
Definition xml.hpp:162
const string & content() const
Definition xml.hpp:302
string & content()
Definition xml.hpp:303
node::string string
Definition xml.hpp:294
xml_text(const string &aContent=string())
Definition xml.hpp:298
xml_node< CharT, Alloc > node
Definition xml.hpp:293
std::basic_ostream< Elem, Traits > & operator<<(std::basic_ostream< Elem, Traits > &aStream, const basic_point< T > &aPoint)
basic_xml< wchar_t, pool_allocator< char > > wxml
Definition xml.hpp:554
basic_xml< char, pool_allocator< char > > xml
Definition xml.hpp:553