Newer
Older
arseny.kapoulkine
committed
/**
* pugixml parser - version 0.7
arseny.kapoulkine
committed
* --------------------------------------------------------
* Copyright (C) 2006-2010, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
arseny.kapoulkine
committed
* Report bugs and download new versions at http://code.google.com/p/pugixml/
*
* This library is distributed under the MIT License. See notice at the end
* of this file.
*
* This work is based on the pugxml parser, which is:
* Copyright (C) 2003, by Kristen Wegner (kristen@tima.net)
*/
arseny.kapoulkine
committed
#ifndef HEADER_PUGIXML_HPP
#define HEADER_PUGIXML_HPP
#include "pugiconfig.hpp"
#ifndef PUGIXML_NO_STL
namespace std
{
struct bidirectional_iterator_tag;
#ifdef __SUNPRO_CC
// Sun C++ compiler has a bug which forces template argument names in forward declarations to be the same as in actual definitions
template <class _T> class allocator;
template <class _charT> struct char_traits;
template <class _charT, class _Traits> class basic_istream;
template <class _charT, class _Traits> class basic_ostream;
template <class _charT, class _Traits, class _Allocator> class basic_string;
#else
// Borland C++ compiler has a bug which forces template argument names in forward declarations to be the same as in actual definitions
template <class _Ty> class allocator;
template <class _Ty> struct char_traits;
template <class _Elem, class _Traits> class basic_istream;
template <class _Elem, class _Traits> class basic_ostream;
template <class _Elem, class _Traits, class _Ax> class basic_string;
// Digital Mars compiler has a bug which requires a forward declaration for explicit instantiation (otherwise type selection is messed up later, producing link errors)
// Also note that we have to declare char_traits as a class here, since it's defined that way
#ifdef __DMC__
template <> class char_traits<char>;
#endif
}
arseny.kapoulkine
committed
#endif
// Macro for deprecated features
#ifndef PUGIXML_DEPRECATED
# if defined(__GNUC__)
# define PUGIXML_DEPRECATED __attribute__((deprecated))
# elif defined(_MSC_VER) && _MSC_VER >= 1300
# define PUGIXML_DEPRECATED __declspec(deprecated)
# else
# define PUGIXML_DEPRECATED
# endif
arseny.kapoulkine
committed
// No XPath without STL or exceptions
#if (defined(PUGIXML_NO_STL) || defined(PUGIXML_NO_EXCEPTIONS)) && !defined(PUGIXML_NO_XPATH)
# define PUGIXML_NO_XPATH
arseny.kapoulkine
committed
#endif
// Include exception header for XPath
#ifndef PUGIXML_NO_XPATH
# include <exception>
#endif
arseny.kapoulkine
committed
// If no API is defined, assume default
#ifndef PUGIXML_API
# define PUGIXML_API
#endif
// If no API for classes is defined, assume default
#ifndef PUGIXML_CLASS
# define PUGIXML_CLASS PUGIXML_API
#endif
// If no API for functions is defined, assume default
#ifndef PUGIXML_FUNCTION
# define PUGIXML_FUNCTION PUGIXML_API
#endif
#include <stddef.h>
// Character interface macros
#ifdef PUGIXML_WCHAR_MODE
# define PUGIXML_TEXT(t) L ## t
namespace pugi
{
/// Character type used for all internal storage and operations; depends on PUGIXML_WCHAR_MODE
typedef wchar_t char_t;
#ifndef PUGIXML_NO_STL
/// String type used for operations that work with STL string; depends on PUGIXML_WCHAR_MODE
typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > string_t;
#endif
}
#else
# define PUGIXML_TEXT(t) t
namespace pugi
{
/// Character type used for all internal storage and operations; depends on PUGIXML_WCHAR_MODE
typedef char char_t;
# ifndef PUGIXML_NO_STL
// GCC 3.4 has a bug which prevents string_t instantiation using char_t, so we have to use char type explicitly
/// String type used for operations that work with STL string; depends on PUGIXML_WCHAR_MODE
typedef std::basic_string<char, std::char_traits<char>, std::allocator<char> > string_t;
# endif
}
#endif
// Helpers for inline implementation
namespace pugi
{
namespace impl
{
bool PUGIXML_FUNCTION strequal(const char_t*, const char_t*);
bool PUGIXML_FUNCTION strequalwild(const char_t*, const char_t*);
arseny.kapoulkine
committed
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
/// The PugiXML Parser namespace.
namespace pugi
{
/// Tree node classification.
enum xml_node_type
{
node_null, ///< Undifferentiated entity
node_document, ///< A document tree's absolute root.
node_element, ///< E.g. '<...>'
node_pcdata, ///< E.g. '>...<'
node_cdata, ///< E.g. '<![CDATA[...]]>'
node_comment, ///< E.g. '<!--...-->'
node_pi, ///< E.g. '<?...?>'
node_declaration ///< E.g. '<?xml ...?>'
};
// Parsing options
/**
* Minimal parsing mode. Equivalent to turning all other flags off. This set of flags means
* that pugixml does not add pi/cdata sections or comments to DOM tree and does not perform
* any conversions for input data, meaning fastest parsing.
*/
const unsigned int parse_minimal = 0x0000;
/**
* This flag determines if processing instructions (nodes with type node_pi; such nodes have the
* form of <? target content ?> or <? target ?> in XML) are to be put in DOM tree. If this flag is off,
* they are not put in the tree, but are still parsed and checked for correctness.
*
* The corresponding node in DOM tree will have type node_pi, name "target" and value "content",
* if any.
*
* Note that <?xml ...?> (document declaration) is not considered to be a PI.
*
* This flag is off by default.
*/
const unsigned int parse_pi = 0x0001;
/**
* This flag determines if comments (nodes with type node_comment; such nodes have the form of
* <!-- content --> in XML) are to be put in DOM tree. If this flag is off, they are not put in
* the tree, but are still parsed and checked for correctness.
*
* The corresponding node in DOM tree will have type node_comment, empty name and value "content".
*
* This flag is off by default.
*/
const unsigned int parse_comments = 0x0002;
/**
* This flag determines if CDATA sections (nodes with type node_cdata; such nodes have the form
* of <![CDATA[[content]]> in XML) are to be put in DOM tree. If this flag is off, they are not
* put in the tree, but are still parsed and checked for correctness.
*
* The corresponding node in DOM tree will have type node_cdata, empty name and value "content".
*
* This flag is on by default.
*/
const unsigned int parse_cdata = 0x0004;
/**
* This flag determines if nodes with PCDATA (regular text) that consist only of whitespace
* characters are to be put in DOM tree. Often whitespace-only data is not significant for the
* application, and the cost of allocating and storing such nodes (both memory and speed-wise)
* can be significant. For example, after parsing XML string "<node> <a/> </node>", <node> element
* will have 3 children when parse_ws_pcdata is set (child with type node_pcdata and value=" ",
* child with type node_element and name "a", and another child with type node_pcdata and
* value=" "), and only 1 child when parse_ws_pcdata is not set.
*
* This flag is off by default.
*/
const unsigned int parse_ws_pcdata = 0x0008;
/**
Loading
Loading full blame...