Fix whitespace issues
Git warns when it finds "whitespace errors". This commit gets rid of these whitespace errors for code and adoc files.
This commit is contained in:
parent
7f91301946
commit
f7aa65db8a
114
docs/manual.adoc
114
docs/manual.adoc
@ -71,7 +71,7 @@ OTHER DEALINGS IN THE SOFTWARE.
|
|||||||
....
|
....
|
||||||
|
|
||||||
This means that you can freely use pugixml in your applications, both open-source and proprietary. If you use pugixml in a product, it is sufficient to add an acknowledgment like this to the product distribution:
|
This means that you can freely use pugixml in your applications, both open-source and proprietary. If you use pugixml in a product, it is sufficient to add an acknowledgment like this to the product distribution:
|
||||||
|
|
||||||
....
|
....
|
||||||
This software is based on pugixml library (http://pugixml.org).
|
This software is based on pugixml library (http://pugixml.org).
|
||||||
pugixml is Copyright (C) 2006-2016 Arseny Kapoulkine.
|
pugixml is Copyright (C) 2006-2016 Arseny Kapoulkine.
|
||||||
@ -142,9 +142,9 @@ Here's an incomplete list of pugixml packages in various systems:
|
|||||||
=== Building pugixml
|
=== Building pugixml
|
||||||
|
|
||||||
pugixml is distributed in source form without any pre-built binaries; you have to build them yourself.
|
pugixml is distributed in source form without any pre-built binaries; you have to build them yourself.
|
||||||
|
|
||||||
The complete pugixml source consists of three files - one source file, `pugixml.cpp`, and two header files, `pugixml.hpp` and `pugiconfig.hpp`. `pugixml.hpp` is the primary header which you need to include in order to use pugixml classes/functions; `pugiconfig.hpp` is a supplementary configuration file (see <<install.building.config>>). The rest of this guide assumes that `pugixml.hpp` is either in the current directory or in one of include directories of your projects, so that `#include "pugixml.hpp"` can find the header; however you can also use relative path (i.e. `#include "../libs/pugixml/src/pugixml.hpp"`) or include directory-relative path (i.e. `#include <xml/thirdparty/pugixml/src/pugixml.hpp>`).
|
The complete pugixml source consists of three files - one source file, `pugixml.cpp`, and two header files, `pugixml.hpp` and `pugiconfig.hpp`. `pugixml.hpp` is the primary header which you need to include in order to use pugixml classes/functions; `pugiconfig.hpp` is a supplementary configuration file (see <<install.building.config>>). The rest of this guide assumes that `pugixml.hpp` is either in the current directory or in one of include directories of your projects, so that `#include "pugixml.hpp"` can find the header; however you can also use relative path (i.e. `#include "../libs/pugixml/src/pugixml.hpp"`) or include directory-relative path (i.e. `#include <xml/thirdparty/pugixml/src/pugixml.hpp>`).
|
||||||
|
|
||||||
[[install.building.embed]]
|
[[install.building.embed]]
|
||||||
==== Building pugixml as a part of another static library/executable
|
==== Building pugixml as a part of another static library/executable
|
||||||
|
|
||||||
@ -165,11 +165,11 @@ The correct way to resolve this is to disable precompiled headers for `pugixml.c
|
|||||||
| image::vs2005_pch3.png[link="images/vs2005_pch3.png"]
|
| image::vs2005_pch3.png[link="images/vs2005_pch3.png"]
|
||||||
| image::vs2005_pch4.png[link="images/vs2005_pch4.png"]
|
| image::vs2005_pch4.png[link="images/vs2005_pch4.png"]
|
||||||
|===
|
|===
|
||||||
|
|
||||||
[[install.building.static]]
|
[[install.building.static]]
|
||||||
==== Building pugixml as a standalone static library
|
==== Building pugixml as a standalone static library
|
||||||
|
|
||||||
It's possible to compile pugixml as a standalone static library. This process depends on the method of building your application; pugixml distribution comes with project files for several popular IDEs/build systems. There are project files for Apple XCode, Code::Blocks, Codelite, Microsoft Visual Studio 2005, 2008, 2010+, and configuration scripts for CMake and premake4. You're welcome to submit project files/build scripts for other software; see <<overview.feedback>>.
|
It's possible to compile pugixml as a standalone static library. This process depends on the method of building your application; pugixml distribution comes with project files for several popular IDEs/build systems. There are project files for Apple XCode, Code::Blocks, Codelite, Microsoft Visual Studio 2005, 2008, 2010+, and configuration scripts for CMake and premake4. You're welcome to submit project files/build scripts for other software; see <<overview.feedback>>.
|
||||||
|
|
||||||
There are two projects for each version of Microsoft Visual Studio: one for dynamically linked CRT, which has a name like `pugixml_vs2008.vcproj`, and another one for statically linked CRT, which has a name like `pugixml_vs2008_static.vcproj`. You should select the version that matches the CRT used in your application; the default option for new projects created by Microsoft Visual Studio is dynamically linked CRT, so unless you changed the defaults, you should use the version with dynamic CRT (i.e. `pugixml_vs2008.vcproj` for Microsoft Visual Studio 2008).
|
There are two projects for each version of Microsoft Visual Studio: one for dynamically linked CRT, which has a name like `pugixml_vs2008.vcproj`, and another one for statically linked CRT, which has a name like `pugixml_vs2008_static.vcproj`. You should select the version that matches the CRT used in your application; the default option for new projects created by Microsoft Visual Studio is dynamically linked CRT, so unless you changed the defaults, you should use the version with dynamic CRT (i.e. `pugixml_vs2008.vcproj` for Microsoft Visual Studio 2008).
|
||||||
|
|
||||||
@ -187,7 +187,7 @@ In addition to adding pugixml project to your workspace, you'll have to make sur
|
|||||||
|
|
||||||
[[install.building.shared]]
|
[[install.building.shared]]
|
||||||
==== Building pugixml as a standalone shared library
|
==== Building pugixml as a standalone shared library
|
||||||
|
|
||||||
It's possible to compile pugixml as a standalone shared library. The process is usually similar to the static library approach; however, no preconfigured projects/scripts are included into pugixml distribution, so you'll have to do it yourself. Generally, if you're using GCC-based toolchain, the process does not differ from building any other library as DLL (adding -shared to compilation flags should suffice); if you're using MSVC-based toolchain, you'll have to explicitly mark exported symbols with a declspec attribute. You can do it by defining <<PUGIXML_API,PUGIXML_API>> macro, i.e. via `pugiconfig.hpp`:
|
It's possible to compile pugixml as a standalone shared library. The process is usually similar to the static library approach; however, no preconfigured projects/scripts are included into pugixml distribution, so you'll have to do it yourself. Generally, if you're using GCC-based toolchain, the process does not differ from building any other library as DLL (adding -shared to compilation flags should suffice); if you're using MSVC-based toolchain, you'll have to explicitly mark exported symbols with a declspec attribute. You can do it by defining <<PUGIXML_API,PUGIXML_API>> macro, i.e. via `pugiconfig.hpp`:
|
||||||
|
|
||||||
[source]
|
[source]
|
||||||
@ -243,7 +243,7 @@ NOTE: In that example `PUGIXML_API` is inconsistent between several source files
|
|||||||
[[PUGIXML_MEMORY_PAGE_SIZE]]`PUGIXML_MEMORY_PAGE_SIZE`, [[PUGIXML_MEMORY_OUTPUT_STACK]]`PUGIXML_MEMORY_OUTPUT_STACK` and [[PUGIXML_MEMORY_XPATH_PAGE_SIZE]]`PUGIXML_MEMORY_XPATH_PAGE_SIZE` can be used to customize certain important sizes to optimize memory usage for the application-specific patterns. For details see <<dom.memory.tuning>>.
|
[[PUGIXML_MEMORY_PAGE_SIZE]]`PUGIXML_MEMORY_PAGE_SIZE`, [[PUGIXML_MEMORY_OUTPUT_STACK]]`PUGIXML_MEMORY_OUTPUT_STACK` and [[PUGIXML_MEMORY_XPATH_PAGE_SIZE]]`PUGIXML_MEMORY_XPATH_PAGE_SIZE` can be used to customize certain important sizes to optimize memory usage for the application-specific patterns. For details see <<dom.memory.tuning>>.
|
||||||
|
|
||||||
[[PUGIXML_HAS_LONG_LONG]]`PUGIXML_HAS_LONG_LONG` define enables support for `long long` type in pugixml. This define is automatically enabled if your platform is known to have `long long` support (i.e. has C{plus}{plus}11 support or uses a reasonably modern version of a known compiler); if pugixml does not recognize that your platform supports `long long` but in fact it does, you can enable the define manually.
|
[[PUGIXML_HAS_LONG_LONG]]`PUGIXML_HAS_LONG_LONG` define enables support for `long long` type in pugixml. This define is automatically enabled if your platform is known to have `long long` support (i.e. has C{plus}{plus}11 support or uses a reasonably modern version of a known compiler); if pugixml does not recognize that your platform supports `long long` but in fact it does, you can enable the define manually.
|
||||||
|
|
||||||
[[install.portability]]
|
[[install.portability]]
|
||||||
=== Portability
|
=== Portability
|
||||||
|
|
||||||
@ -451,7 +451,7 @@ you'll have to use
|
|||||||
|
|
||||||
`xml_node node = doc.child(L"bookstore").find_child_by_attribute(L"book", L"id", L"12345");`
|
`xml_node node = doc.child(L"bookstore").find_child_by_attribute(L"book", L"id", L"12345");`
|
||||||
====
|
====
|
||||||
|
|
||||||
[[dom.thread]]
|
[[dom.thread]]
|
||||||
=== Thread-safety guarantees
|
=== Thread-safety guarantees
|
||||||
|
|
||||||
@ -509,11 +509,11 @@ This is a simple example of custom memory management (link:samples/custom_memory
|
|||||||
|
|
||||||
[source,indent=0]
|
[source,indent=0]
|
||||||
----
|
----
|
||||||
include::samples/custom_memory_management.cpp[tags=decl]
|
include::samples/custom_memory_management.cpp[tags=decl]
|
||||||
----
|
----
|
||||||
[source,indent=0]
|
[source,indent=0]
|
||||||
----
|
----
|
||||||
include::samples/custom_memory_management.cpp[tags=call]
|
include::samples/custom_memory_management.cpp[tags=call]
|
||||||
----
|
----
|
||||||
|
|
||||||
When setting new memory management functions, care must be taken to make sure that there are no live pugixml objects. Otherwise when the objects are destroyed, the new deallocation function will be called with the memory obtained by the old allocation function, resulting in undefined behavior.
|
When setting new memory management functions, care must be taken to make sure that there are no live pugixml objects. Otherwise when the objects are destroyed, the new deallocation function will be called with the memory obtained by the old allocation function, resulting in undefined behavior.
|
||||||
@ -569,7 +569,7 @@ The most common source of XML data is files; pugixml provides dedicated function
|
|||||||
xml_parse_result xml_document::load_file(const char* path, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
|
xml_parse_result xml_document::load_file(const char* path, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
|
||||||
xml_parse_result xml_document::load_file(const wchar_t* path, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
|
xml_parse_result xml_document::load_file(const wchar_t* path, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
|
||||||
----
|
----
|
||||||
|
|
||||||
These functions accept the file path as its first argument, and also two optional arguments, which specify parsing options (see <<loading.options>>) and input data encoding (see <<loading.encoding>>). The path has the target operating system format, so it can be a relative or absolute one, it should have the delimiters of the target system, it should have the exact case if the target file system is case-sensitive, etc.
|
These functions accept the file path as its first argument, and also two optional arguments, which specify parsing options (see <<loading.options>>) and input data encoding (see <<loading.encoding>>). The path has the target operating system format, so it can be a relative or absolute one, it should have the delimiters of the target system, it should have the exact case if the target file system is case-sensitive, etc.
|
||||||
|
|
||||||
File path is passed to the system file opening function as is in case of the first function (which accepts `const char* path`); the second function either uses a special file opening function if it is provided by the runtime library or converts the path to UTF-8 and uses the system file opening function.
|
File path is passed to the system file opening function as is in case of the first function (which accepts `const char* path`); the second function either uses a special file opening function if it is provided by the runtime library or converts the path to UTF-8 and uses the system file opening function.
|
||||||
@ -580,7 +580,7 @@ This is an example of loading XML document from file (link:samples/load_file.cpp
|
|||||||
|
|
||||||
[source,indent=0]
|
[source,indent=0]
|
||||||
----
|
----
|
||||||
include::samples/load_file.cpp[tags=code]
|
include::samples/load_file.cpp[tags=code]
|
||||||
----
|
----
|
||||||
|
|
||||||
[[loading.memory]]
|
[[loading.memory]]
|
||||||
@ -616,25 +616,25 @@ This is an example of loading XML document from memory using different functions
|
|||||||
|
|
||||||
[source,indent=0]
|
[source,indent=0]
|
||||||
----
|
----
|
||||||
include::samples/load_memory.cpp[tags=decl]
|
include::samples/load_memory.cpp[tags=decl]
|
||||||
----
|
----
|
||||||
[source,indent=0]
|
[source,indent=0]
|
||||||
----
|
----
|
||||||
include::samples/load_memory.cpp[tags=load_buffer]
|
include::samples/load_memory.cpp[tags=load_buffer]
|
||||||
----
|
----
|
||||||
[source,indent=0]
|
[source,indent=0]
|
||||||
----
|
----
|
||||||
include::samples/load_memory.cpp[tags=load_buffer_inplace_begin]
|
include::samples/load_memory.cpp[tags=load_buffer_inplace_begin]
|
||||||
|
|
||||||
include::samples/load_memory.cpp[tags=load_buffer_inplace_end]
|
include::samples/load_memory.cpp[tags=load_buffer_inplace_end]
|
||||||
----
|
----
|
||||||
[source,indent=0]
|
[source,indent=0]
|
||||||
----
|
----
|
||||||
include::samples/load_memory.cpp[tags=load_buffer_inplace_own]
|
include::samples/load_memory.cpp[tags=load_buffer_inplace_own]
|
||||||
----
|
----
|
||||||
[source,indent=0]
|
[source,indent=0]
|
||||||
----
|
----
|
||||||
include::samples/load_memory.cpp[tags=load_string]
|
include::samples/load_memory.cpp[tags=load_string]
|
||||||
----
|
----
|
||||||
|
|
||||||
[[loading.stream]]
|
[[loading.stream]]
|
||||||
@ -657,7 +657,7 @@ This is a simple example of loading XML document from file using streams (link:s
|
|||||||
|
|
||||||
[source,indent=0]
|
[source,indent=0]
|
||||||
----
|
----
|
||||||
include::samples/load_stream.cpp[tags=code]
|
include::samples/load_stream.cpp[tags=code]
|
||||||
----
|
----
|
||||||
|
|
||||||
[[loading.errors]]
|
[[loading.errors]]
|
||||||
@ -718,7 +718,7 @@ This is an example of handling loading errors (link:samples/load_error_handling.
|
|||||||
|
|
||||||
[source,indent=0]
|
[source,indent=0]
|
||||||
----
|
----
|
||||||
include::samples/load_error_handling.cpp[tags=code]
|
include::samples/load_error_handling.cpp[tags=code]
|
||||||
----
|
----
|
||||||
|
|
||||||
[[loading.options]]
|
[[loading.options]]
|
||||||
@ -777,7 +777,7 @@ This is an example of using different parsing options (link:samples/load_options
|
|||||||
|
|
||||||
[source,indent=0]
|
[source,indent=0]
|
||||||
----
|
----
|
||||||
include::samples/load_options.cpp[tags=code]
|
include::samples/load_options.cpp[tags=code]
|
||||||
----
|
----
|
||||||
|
|
||||||
[[loading.encoding]]
|
[[loading.encoding]]
|
||||||
@ -838,7 +838,7 @@ pugixml features an extensive interface for getting various types of data from t
|
|||||||
|
|
||||||
[[xml_node::parent]][[xml_node::first_child]][[xml_node::last_child]][[xml_node::next_sibling]][[xml_node::previous_sibling]][[xml_node::first_attribute]][[xml_node::last_attribute]][[xml_attribute::next_attribute]][[xml_attribute::previous_attribute]]
|
[[xml_node::parent]][[xml_node::first_child]][[xml_node::last_child]][[xml_node::next_sibling]][[xml_node::previous_sibling]][[xml_node::first_attribute]][[xml_node::last_attribute]][[xml_attribute::next_attribute]][[xml_attribute::previous_attribute]]
|
||||||
The internal representation of the document is a tree, where each node has a list of child nodes (the order of children corresponds to their order in the XML representation), and additionally element nodes have a list of attributes, which is also ordered. Several functions are provided in order to let you get from one node in the tree to the other. These functions roughly correspond to the internal representation, and thus are usually building blocks for other methods of traversing (i.e. XPath traversals are based on these functions).
|
The internal representation of the document is a tree, where each node has a list of child nodes (the order of children corresponds to their order in the XML representation), and additionally element nodes have a list of attributes, which is also ordered. Several functions are provided in order to let you get from one node in the tree to the other. These functions roughly correspond to the internal representation, and thus are usually building blocks for other methods of traversing (i.e. XPath traversals are based on these functions).
|
||||||
|
|
||||||
[source]
|
[source]
|
||||||
----
|
----
|
||||||
xml_node xml_node::parent() const;
|
xml_node xml_node::parent() const;
|
||||||
@ -863,7 +863,7 @@ With these functions, you can iterate through all child nodes and display all at
|
|||||||
|
|
||||||
[source,indent=0]
|
[source,indent=0]
|
||||||
----
|
----
|
||||||
include::samples/traverse_base.cpp[tags=basic]
|
include::samples/traverse_base.cpp[tags=basic]
|
||||||
----
|
----
|
||||||
|
|
||||||
[[access.nodedata]]
|
[[access.nodedata]]
|
||||||
@ -922,7 +922,7 @@ It returns `def` argument if the attribute handle is null. If you do not specify
|
|||||||
|
|
||||||
[[xml_attribute::as_int]][[xml_attribute::as_uint]][[xml_attribute::as_double]][[xml_attribute::as_float]][[xml_attribute::as_bool]][[xml_attribute::as_llong]][[xml_attribute::as_ullong]]
|
[[xml_attribute::as_int]][[xml_attribute::as_uint]][[xml_attribute::as_double]][[xml_attribute::as_float]][[xml_attribute::as_bool]][[xml_attribute::as_llong]][[xml_attribute::as_ullong]]
|
||||||
In many cases attribute values have types that are not strings - i.e. an attribute may always contain values that should be treated as integers, despite the fact that they are represented as strings in XML. pugixml provides several accessors that convert attribute value to some other type:
|
In many cases attribute values have types that are not strings - i.e. an attribute may always contain values that should be treated as integers, despite the fact that they are represented as strings in XML. pugixml provides several accessors that convert attribute value to some other type:
|
||||||
|
|
||||||
[source]
|
[source]
|
||||||
----
|
----
|
||||||
int xml_attribute::as_int(int def = 0) const;
|
int xml_attribute::as_int(int def = 0) const;
|
||||||
@ -949,7 +949,7 @@ This is an example of using these functions, along with node data retrieval ones
|
|||||||
|
|
||||||
[source,indent=0]
|
[source,indent=0]
|
||||||
----
|
----
|
||||||
include::samples/traverse_base.cpp[tags=data]
|
include::samples/traverse_base.cpp[tags=data]
|
||||||
----
|
----
|
||||||
|
|
||||||
[[access.contents]]
|
[[access.contents]]
|
||||||
@ -992,7 +992,7 @@ This is an example of using these functions (link:samples/traverse_base.cpp[]):
|
|||||||
|
|
||||||
[source,indent=0]
|
[source,indent=0]
|
||||||
----
|
----
|
||||||
include::samples/traverse_base.cpp[tags=contents]
|
include::samples/traverse_base.cpp[tags=contents]
|
||||||
----
|
----
|
||||||
|
|
||||||
[[access.rangefor]]
|
[[access.rangefor]]
|
||||||
@ -1014,7 +1014,7 @@ This is an example of using these functions (link:samples/traverse_rangefor.cpp[
|
|||||||
|
|
||||||
[source,indent=0]
|
[source,indent=0]
|
||||||
----
|
----
|
||||||
include::samples/traverse_rangefor.cpp[tags=code]
|
include::samples/traverse_rangefor.cpp[tags=code]
|
||||||
----
|
----
|
||||||
|
|
||||||
[[access.iterators]]
|
[[access.iterators]]
|
||||||
@ -1047,7 +1047,7 @@ Here is an example of using iterators for document traversal (link:samples/trave
|
|||||||
|
|
||||||
[source,indent=0]
|
[source,indent=0]
|
||||||
----
|
----
|
||||||
include::samples/traverse_iter.cpp[tags=code]
|
include::samples/traverse_iter.cpp[tags=code]
|
||||||
----
|
----
|
||||||
|
|
||||||
CAUTION: Node and attribute iterators are somewhere in the middle between const and non-const iterators. While dereference operation yields a non-constant reference to the object, so that you can use it for tree modification operations, modifying this reference using assignment - i.e. passing iterators to a function like `std::sort` - will not give expected results, as assignment modifies local handle that's stored in the iterator.
|
CAUTION: Node and attribute iterators are somewhere in the middle between const and non-const iterators. While dereference operation yields a non-constant reference to the object, so that you can use it for tree modification operations, modifying this reference using assignment - i.e. passing iterators to a function like `std::sort` - will not give expected results, as assignment modifies local handle that's stored in the iterator.
|
||||||
@ -1089,11 +1089,11 @@ This is an example of traversing tree hierarchy with xml_tree_walker (link:sampl
|
|||||||
|
|
||||||
[source,indent=0]
|
[source,indent=0]
|
||||||
----
|
----
|
||||||
include::samples/traverse_walker.cpp[tags=impl]
|
include::samples/traverse_walker.cpp[tags=impl]
|
||||||
----
|
----
|
||||||
[source,indent=0]
|
[source,indent=0]
|
||||||
----
|
----
|
||||||
include::samples/traverse_walker.cpp[tags=traverse]
|
include::samples/traverse_walker.cpp[tags=traverse]
|
||||||
----
|
----
|
||||||
|
|
||||||
[[access.predicate]]
|
[[access.predicate]]
|
||||||
@ -1121,11 +1121,11 @@ This is an example of using predicate-based functions (link:samples/traverse_pre
|
|||||||
|
|
||||||
[source,indent=0]
|
[source,indent=0]
|
||||||
----
|
----
|
||||||
include::samples/traverse_predicate.cpp[tags=decl]
|
include::samples/traverse_predicate.cpp[tags=decl]
|
||||||
----
|
----
|
||||||
[source,indent=0]
|
[source,indent=0]
|
||||||
----
|
----
|
||||||
include::samples/traverse_predicate.cpp[tags=find]
|
include::samples/traverse_predicate.cpp[tags=find]
|
||||||
----
|
----
|
||||||
|
|
||||||
[[access.text]]
|
[[access.text]]
|
||||||
@ -1136,7 +1136,7 @@ It is common to store data as text contents of some node - i.e. `<node><descript
|
|||||||
|
|
||||||
[[xml_node::text]]
|
[[xml_node::text]]
|
||||||
You can get the text object from a node by using `text()` method:
|
You can get the text object from a node by using `text()` method:
|
||||||
|
|
||||||
[source]
|
[source]
|
||||||
----
|
----
|
||||||
xml_text xml_node::text() const;
|
xml_text xml_node::text() const;
|
||||||
@ -1193,7 +1193,7 @@ This is an example of using `xml_text` object (link:samples/text.cpp[]):
|
|||||||
|
|
||||||
[source,indent=0]
|
[source,indent=0]
|
||||||
----
|
----
|
||||||
include::samples/text.cpp[tags=access]
|
include::samples/text.cpp[tags=access]
|
||||||
----
|
----
|
||||||
|
|
||||||
[[access.misc]]
|
[[access.misc]]
|
||||||
@ -1220,7 +1220,7 @@ xml_node xml_node::first_element_by_path(const char_t* path, char_t delimiter =
|
|||||||
|
|
||||||
Node paths consist of node names, separated with a delimiter (which is `/` by default); also paths can contain self (`.`) and parent (`..`) pseudo-names, so that this is a valid path: `"../../foo/./bar"`. `path` returns the path to the node from the document root, `first_element_by_path` looks for a node represented by a given path; a path can be an absolute one (absolute paths start with the delimiter), in which case the rest of the path is treated as document root relative, and relative to the given node. For example, in the following document: `<a><b><c/></b></a>`, node `<c/>` has path `"a/b/c"`; calling `first_element_by_path` for document with path `"a/b"` results in node `<b/>`; calling `first_element_by_path` for node `<a/>` with path `"../a/./b/../."` results in node `<a/>`; calling `first_element_by_path` with path `"/a"` results in node `<a/>` for any node.
|
Node paths consist of node names, separated with a delimiter (which is `/` by default); also paths can contain self (`.`) and parent (`..`) pseudo-names, so that this is a valid path: `"../../foo/./bar"`. `path` returns the path to the node from the document root, `first_element_by_path` looks for a node represented by a given path; a path can be an absolute one (absolute paths start with the delimiter), in which case the rest of the path is treated as document root relative, and relative to the given node. For example, in the following document: `<a><b><c/></b></a>`, node `<c/>` has path `"a/b/c"`; calling `first_element_by_path` for document with path `"a/b"` results in node `<b/>`; calling `first_element_by_path` for node `<a/>` with path `"../a/./b/../."` results in node `<a/>`; calling `first_element_by_path` with path `"/a"` results in node `<a/>` for any node.
|
||||||
|
|
||||||
In case path component is ambiguous (if there are two nodes with given name), the first one is selected; paths are not guaranteed to uniquely identify nodes in a document. If any component of a path is not found, the result of `first_element_by_path` is null node; also `first_element_by_path` returns null node for null nodes, in which case the path does not matter. `path` returns an empty string for null nodes.
|
In case path component is ambiguous (if there are two nodes with given name), the first one is selected; paths are not guaranteed to uniquely identify nodes in a document. If any component of a path is not found, the result of `first_element_by_path` is null node; also `first_element_by_path` returns null node for null nodes, in which case the path does not matter. `path` returns an empty string for null nodes.
|
||||||
|
|
||||||
NOTE: `path` function returns the result as STL string, and thus is not available if <<PUGIXML_NO_STL,PUGIXML_NO_STL>> is defined.
|
NOTE: `path` function returns the result as STL string, and thus is not available if <<PUGIXML_NO_STL,PUGIXML_NO_STL>> is defined.
|
||||||
|
|
||||||
@ -1261,7 +1261,7 @@ This is an example of setting node name and value (link:samples/modify_base.cpp[
|
|||||||
|
|
||||||
[source,indent=0]
|
[source,indent=0]
|
||||||
----
|
----
|
||||||
include::samples/modify_base.cpp[tags=node]
|
include::samples/modify_base.cpp[tags=node]
|
||||||
----
|
----
|
||||||
|
|
||||||
[[modify.attrdata]]
|
[[modify.attrdata]]
|
||||||
@ -1290,7 +1290,7 @@ bool xml_attribute::set_value(bool rhs);
|
|||||||
bool xml_attribute::set_value(long long rhs);
|
bool xml_attribute::set_value(long long rhs);
|
||||||
bool xml_attribute::set_value(unsigned long long rhs);
|
bool xml_attribute::set_value(unsigned long long rhs);
|
||||||
----
|
----
|
||||||
|
|
||||||
The above functions convert the argument to string and then call the base `set_value` function. Integers are converted to a decimal form, floating-point numbers are converted to either decimal or scientific form, depending on the number magnitude, boolean values are converted to either `"true"` or `"false"`.
|
The above functions convert the argument to string and then call the base `set_value` function. Integers are converted to a decimal form, floating-point numbers are converted to either decimal or scientific form, depending on the number magnitude, boolean values are converted to either `"true"` or `"false"`.
|
||||||
|
|
||||||
CAUTION: Number conversion functions depend on current C locale as set with `setlocale`, so may generate unexpected results if the locale is different from `"C"`.
|
CAUTION: Number conversion functions depend on current C locale as set with `setlocale`, so may generate unexpected results if the locale is different from `"C"`.
|
||||||
@ -1319,7 +1319,7 @@ This is an example of setting attribute name and value (link:samples/modify_base
|
|||||||
|
|
||||||
[source,indent=0]
|
[source,indent=0]
|
||||||
----
|
----
|
||||||
include::samples/modify_base.cpp[tags=attr]
|
include::samples/modify_base.cpp[tags=attr]
|
||||||
----
|
----
|
||||||
|
|
||||||
[[modify.add]]
|
[[modify.add]]
|
||||||
@ -1368,7 +1368,7 @@ This is an example of adding new attributes/nodes to the document (link:samples/
|
|||||||
|
|
||||||
[source,indent=0]
|
[source,indent=0]
|
||||||
----
|
----
|
||||||
include::samples/modify_add.cpp[tags=code]
|
include::samples/modify_add.cpp[tags=code]
|
||||||
----
|
----
|
||||||
|
|
||||||
[[modify.remove]]
|
[[modify.remove]]
|
||||||
@ -1405,7 +1405,7 @@ This is an example of removing attributes/nodes from the document (link:samples/
|
|||||||
|
|
||||||
[source,indent=0]
|
[source,indent=0]
|
||||||
----
|
----
|
||||||
include::samples/modify_remove.cpp[tags=code]
|
include::samples/modify_remove.cpp[tags=code]
|
||||||
----
|
----
|
||||||
|
|
||||||
[[modify.text]]
|
[[modify.text]]
|
||||||
@ -1436,7 +1436,7 @@ bool xml_text::set(bool rhs);
|
|||||||
bool xml_text::set(long long rhs);
|
bool xml_text::set(long long rhs);
|
||||||
bool xml_text::set(unsigned long long rhs);
|
bool xml_text::set(unsigned long long rhs);
|
||||||
----
|
----
|
||||||
|
|
||||||
The above functions convert the argument to string and then call the base `set` function. These functions have the same semantics as similar `xml_attribute` functions. You can <<xml_attribute::set_value,refer to documentation for the attribute functions>> for details.
|
The above functions convert the argument to string and then call the base `set` function. These functions have the same semantics as similar `xml_attribute` functions. You can <<xml_attribute::set_value,refer to documentation for the attribute functions>> for details.
|
||||||
|
|
||||||
[[xml_text::assign]]
|
[[xml_text::assign]]
|
||||||
@ -1461,7 +1461,7 @@ This is an example of using `xml_text` object to modify text contents (link:samp
|
|||||||
|
|
||||||
[source,indent=0]
|
[source,indent=0]
|
||||||
----
|
----
|
||||||
include::samples/text.cpp[tags=modify]
|
include::samples/text.cpp[tags=modify]
|
||||||
----
|
----
|
||||||
|
|
||||||
[[modify.clone]]
|
[[modify.clone]]
|
||||||
@ -1497,7 +1497,7 @@ This is an example with one possible implementation of include tags in XML (link
|
|||||||
|
|
||||||
[source,indent=0]
|
[source,indent=0]
|
||||||
----
|
----
|
||||||
include::samples/include.cpp[tags=code]
|
include::samples/include.cpp[tags=code]
|
||||||
----
|
----
|
||||||
|
|
||||||
[[modify.move]]
|
[[modify.move]]
|
||||||
@ -1600,7 +1600,7 @@ This is a simple example of saving XML document to file (link:samples/save_file.
|
|||||||
|
|
||||||
[source,indent=0]
|
[source,indent=0]
|
||||||
----
|
----
|
||||||
include::samples/save_file.cpp[tags=code]
|
include::samples/save_file.cpp[tags=code]
|
||||||
----
|
----
|
||||||
|
|
||||||
[[saving.stream]]
|
[[saving.stream]]
|
||||||
@ -1624,7 +1624,7 @@ This is a simple example of saving XML document to standard output (link:samples
|
|||||||
|
|
||||||
[source,indent=0]
|
[source,indent=0]
|
||||||
----
|
----
|
||||||
include::samples/save_stream.cpp[tags=code]
|
include::samples/save_stream.cpp[tags=code]
|
||||||
----
|
----
|
||||||
|
|
||||||
[[saving.writer]]
|
[[saving.writer]]
|
||||||
@ -1652,7 +1652,7 @@ This is a simple example of custom writer for saving document data to STL string
|
|||||||
|
|
||||||
[source,indent=0]
|
[source,indent=0]
|
||||||
----
|
----
|
||||||
include::samples/save_custom_writer.cpp[tags=code]
|
include::samples/save_custom_writer.cpp[tags=code]
|
||||||
----
|
----
|
||||||
|
|
||||||
[[saving.subtree]]
|
[[saving.subtree]]
|
||||||
@ -1674,7 +1674,7 @@ Saving a subtree differs from saving the whole document: the process behaves as
|
|||||||
|
|
||||||
[source,indent=0]
|
[source,indent=0]
|
||||||
----
|
----
|
||||||
include::samples/save_subtree.cpp[tags=code]
|
include::samples/save_subtree.cpp[tags=code]
|
||||||
----
|
----
|
||||||
|
|
||||||
[[saving.options]]
|
[[saving.options]]
|
||||||
@ -1711,7 +1711,7 @@ This is an example that shows the outputs of different output options (link:samp
|
|||||||
|
|
||||||
[source,indent=0]
|
[source,indent=0]
|
||||||
----
|
----
|
||||||
include::samples/save_options.cpp[tags=code]
|
include::samples/save_options.cpp[tags=code]
|
||||||
----
|
----
|
||||||
|
|
||||||
[[saving.encoding]]
|
[[saving.encoding]]
|
||||||
@ -1738,7 +1738,7 @@ This is an example that shows how to create a custom declaration node (link:samp
|
|||||||
|
|
||||||
[source,indent=0]
|
[source,indent=0]
|
||||||
----
|
----
|
||||||
include::samples/save_declaration.cpp[tags=code]
|
include::samples/save_declaration.cpp[tags=code]
|
||||||
----
|
----
|
||||||
|
|
||||||
[[xpath]]
|
[[xpath]]
|
||||||
@ -1872,7 +1872,7 @@ This is an example of selecting nodes using XPath expressions (link:samples/xpat
|
|||||||
|
|
||||||
[source,indent=0]
|
[source,indent=0]
|
||||||
----
|
----
|
||||||
include::samples/xpath_select.cpp[tags=code]
|
include::samples/xpath_select.cpp[tags=code]
|
||||||
----
|
----
|
||||||
|
|
||||||
[[xpath.query]]
|
[[xpath.query]]
|
||||||
@ -1927,7 +1927,7 @@ Note that `evaluate_string` function returns the STL string; as such, it's not a
|
|||||||
size_t xpath_query::evaluate_string(char_t* buffer, size_t capacity, const xpath_node& n) const;
|
size_t xpath_query::evaluate_string(char_t* buffer, size_t capacity, const xpath_node& n) const;
|
||||||
----
|
----
|
||||||
|
|
||||||
This function evaluates the string, and then writes the result to `buffer` (but at most `capacity` characters); then it returns the full size of the result in characters, including the terminating zero. If `capacity` is not 0, the resulting buffer is always zero-terminated. You can use this function as follows:
|
This function evaluates the string, and then writes the result to `buffer` (but at most `capacity` characters); then it returns the full size of the result in characters, including the terminating zero. If `capacity` is not 0, the resulting buffer is always zero-terminated. You can use this function as follows:
|
||||||
|
|
||||||
* First call the function with `buffer = 0` and `capacity = 0`; then allocate the returned amount of characters, and call the function again, passing the allocated storage and the amount of characters;
|
* First call the function with `buffer = 0` and `capacity = 0`; then allocate the returned amount of characters, and call the function again, passing the allocated storage and the amount of characters;
|
||||||
* First call the function with small buffer and buffer capacity; then, if the result is larger than the capacity, the output has been trimmed, so allocate a larger buffer and call the function again.
|
* First call the function with small buffer and buffer capacity; then, if the result is larger than the capacity, the output has been trimmed, so allocate a larger buffer and call the function again.
|
||||||
@ -1936,7 +1936,7 @@ This is an example of using query objects (link:samples/xpath_query.cpp[]):
|
|||||||
|
|
||||||
[source,indent=0]
|
[source,indent=0]
|
||||||
----
|
----
|
||||||
include::samples/xpath_query.cpp[tags=code]
|
include::samples/xpath_query.cpp[tags=code]
|
||||||
----
|
----
|
||||||
|
|
||||||
[[xpath.variables]]
|
[[xpath.variables]]
|
||||||
@ -2040,7 +2040,7 @@ This is an example of using variables in XPath queries (link:samples/xpath_varia
|
|||||||
|
|
||||||
[source,indent=0]
|
[source,indent=0]
|
||||||
----
|
----
|
||||||
include::samples/xpath_variables.cpp[tags=code]
|
include::samples/xpath_variables.cpp[tags=code]
|
||||||
----
|
----
|
||||||
|
|
||||||
[[xpath.errors]]
|
[[xpath.errors]]
|
||||||
@ -2064,7 +2064,7 @@ If exceptions are disabled, then in the event of parsing failure the query is in
|
|||||||
----
|
----
|
||||||
const xpath_parse_result& xpath_query::result() const;
|
const xpath_parse_result& xpath_query::result() const;
|
||||||
----
|
----
|
||||||
|
|
||||||
Without exceptions, evaluating invalid query results in `false`, empty string, `NaN` or an empty node set, depending on the type; evaluating a query as a node set results in an empty node set if the return type is not node set.
|
Without exceptions, evaluating invalid query results in `false`, empty string, `NaN` or an empty node set, depending on the type; evaluating a query as a node set results in an empty node set if the return type is not node set.
|
||||||
|
|
||||||
[[xpath_parse_result]]
|
[[xpath_parse_result]]
|
||||||
@ -2098,7 +2098,7 @@ This is an example of XPath error handling (link:samples/xpath_error.cpp[]):
|
|||||||
|
|
||||||
[source,indent=0]
|
[source,indent=0]
|
||||||
----
|
----
|
||||||
include::samples/xpath_error.cpp[tags=code]
|
include::samples/xpath_error.cpp[tags=code]
|
||||||
----
|
----
|
||||||
|
|
||||||
[[xpath.w3c]]
|
[[xpath.w3c]]
|
||||||
@ -2618,7 +2618,7 @@ const unsigned int +++<a href="#parse_embed_pcdata">parse_embed_pcdata</a>+++
|
|||||||
const unsigned int +++<a href="#parse_wconv_attribute">parse_wconv_attribute</a>+++
|
const unsigned int +++<a href="#parse_wconv_attribute">parse_wconv_attribute</a>+++
|
||||||
const unsigned int +++<a href="#parse_wnorm_attribute">parse_wnorm_attribute</a>+++
|
const unsigned int +++<a href="#parse_wnorm_attribute">parse_wnorm_attribute</a>+++
|
||||||
----
|
----
|
||||||
|
|
||||||
[[apiref.classes]]
|
[[apiref.classes]]
|
||||||
=== Classes
|
=== Classes
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ https://github.com/zeux/pugixml/releases/download/v{version}/pugixml-{version}.t
|
|||||||
The distribution contains library source, documentation (the guide you're reading now and the manual) and some code examples. After downloading the distribution, install pugixml by extracting all files from the compressed archive.
|
The distribution contains library source, documentation (the guide you're reading now and the manual) and some code examples. After downloading the distribution, install pugixml by extracting all files from the compressed archive.
|
||||||
|
|
||||||
The complete pugixml source consists of three files - one source file, `pugixml.cpp`, and two header files, `pugixml.hpp` and `pugiconfig.hpp`. `pugixml.hpp` is the primary header which you need to include in order to use pugixml classes/functions. The rest of this guide assumes that `pugixml.hpp` is either in the current directory or in one of include directories of your projects, so that `#include "pugixml.hpp"` can find the header; however you can also use relative path (i.e. `#include "../libs/pugixml/src/pugixml.hpp"`) or include directory-relative path (i.e. `#include <xml/thirdparty/pugixml/src/pugixml.hpp>`).
|
The complete pugixml source consists of three files - one source file, `pugixml.cpp`, and two header files, `pugixml.hpp` and `pugiconfig.hpp`. `pugixml.hpp` is the primary header which you need to include in order to use pugixml classes/functions. The rest of this guide assumes that `pugixml.hpp` is either in the current directory or in one of include directories of your projects, so that `#include "pugixml.hpp"` can find the header; however you can also use relative path (i.e. `#include "../libs/pugixml/src/pugixml.hpp"`) or include directory-relative path (i.e. `#include <xml/thirdparty/pugixml/src/pugixml.hpp>`).
|
||||||
|
|
||||||
The easiest way to build pugixml is to compile the source file, `pugixml.cpp`, along with the existing library/executable. This process depends on the method of building your application; for example, if you're using Microsoft Visual Studio footnote:[All trademarks used are properties of their respective owners.], Apple Xcode, Code::Blocks or any other IDE, just add `pugixml.cpp` to one of your projects. There are other building methods available, including building pugixml as a standalone static/shared library; link:manual/install.html#install.building[read the manual] for further information.
|
The easiest way to build pugixml is to compile the source file, `pugixml.cpp`, along with the existing library/executable. This process depends on the method of building your application; for example, if you're using Microsoft Visual Studio footnote:[All trademarks used are properties of their respective owners.], Apple Xcode, Code::Blocks or any other IDE, just add `pugixml.cpp` to one of your projects. There are other building methods available, including building pugixml as a standalone static/shared library; link:manual/install.html#install.building[read the manual] for further information.
|
||||||
|
|
||||||
[[dom]]
|
[[dom]]
|
||||||
@ -67,7 +67,7 @@ This is an example of loading XML document from file (link:samples/load_file.cpp
|
|||||||
|
|
||||||
[source,indent=0]
|
[source,indent=0]
|
||||||
----
|
----
|
||||||
include::samples/load_file.cpp[tags=code]
|
include::samples/load_file.cpp[tags=code]
|
||||||
----
|
----
|
||||||
|
|
||||||
`load_file`, as well as other loading functions, destroys the existing document tree and then tries to load the new tree from the specified file. The result of the operation is returned in an `xml_parse_result` object; this object contains the operation status, and the related information (i.e. last successfully parsed position in the input file, if parsing fails).
|
`load_file`, as well as other loading functions, destroys the existing document tree and then tries to load the new tree from the specified file. The result of the operation is returned in an `xml_parse_result` object; this object contains the operation status, and the related information (i.e. last successfully parsed position in the input file, if parsing fails).
|
||||||
@ -78,7 +78,7 @@ This is an example of handling loading errors (link:samples/load_error_handling.
|
|||||||
|
|
||||||
[source,indent=0]
|
[source,indent=0]
|
||||||
----
|
----
|
||||||
include::samples/load_error_handling.cpp[tags=code]
|
include::samples/load_error_handling.cpp[tags=code]
|
||||||
----
|
----
|
||||||
|
|
||||||
Sometimes XML data should be loaded from some other source than file, i.e. HTTP URL; also you may want to load XML data from file using non-standard functions, i.e. to use your virtual file system facilities or to load XML from gzip-compressed files. These scenarios either require loading document from memory, in which case you should prepare a contiguous memory block with all XML data and to pass it to one of buffer loading functions, or loading document from C{plus}{plus} IOstream, in which case you should provide an object which implements `std::istream` or `std::wistream` interface.
|
Sometimes XML data should be loaded from some other source than file, i.e. HTTP URL; also you may want to load XML data from file using non-standard functions, i.e. to use your virtual file system facilities or to load XML from gzip-compressed files. These scenarios either require loading document from memory, in which case you should prepare a contiguous memory block with all XML data and to pass it to one of buffer loading functions, or loading document from C{plus}{plus} IOstream, in which case you should provide an object which implements `std::istream` or `std::wistream` interface.
|
||||||
@ -280,7 +280,7 @@ OTHER DEALINGS IN THE SOFTWARE.
|
|||||||
....
|
....
|
||||||
|
|
||||||
This means that you can freely use pugixml in your applications, both open-source and proprietary. If you use pugixml in a product, it is sufficient to add an acknowledgment like this to the product distribution:
|
This means that you can freely use pugixml in your applications, both open-source and proprietary. If you use pugixml in a product, it is sufficient to add an acknowledgment like this to the product distribution:
|
||||||
|
|
||||||
....
|
....
|
||||||
This software is based on pugixml library (http://pugixml.org).
|
This software is based on pugixml library (http://pugixml.org).
|
||||||
pugixml is Copyright (C) 2006-2016 Arseny Kapoulkine.
|
pugixml is Copyright (C) 2006-2016 Arseny Kapoulkine.
|
||||||
|
@ -48,7 +48,7 @@ bool preprocess(pugi::xml_node node)
|
|||||||
bool load_preprocess(pugi::xml_document& doc, const char* path)
|
bool load_preprocess(pugi::xml_document& doc, const char* path)
|
||||||
{
|
{
|
||||||
pugi::xml_parse_result result = doc.load_file(path, pugi::parse_default | pugi::parse_pi); // for <?include?>
|
pugi::xml_parse_result result = doc.load_file(path, pugi::parse_default | pugi::parse_pi); // for <?include?>
|
||||||
|
|
||||||
return result ? preprocess(doc) : false;
|
return result ? preprocess(doc) : false;
|
||||||
}
|
}
|
||||||
// end::code[]
|
// end::code[]
|
||||||
|
@ -15,7 +15,7 @@ int main()
|
|||||||
decl.append_attribute("encoding") = "UTF-8";
|
decl.append_attribute("encoding") = "UTF-8";
|
||||||
decl.append_attribute("standalone") = "no";
|
decl.append_attribute("standalone") = "no";
|
||||||
|
|
||||||
// <?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
// <?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
// <foo bar="baz">
|
// <foo bar="baz">
|
||||||
// <call>hey</call>
|
// <call>hey</call>
|
||||||
// </foo>
|
// </foo>
|
||||||
|
@ -8,7 +8,7 @@ set(BUILD_DEFINES "" CACHE STRING "Build defines")
|
|||||||
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
option(STATIC_CRT "Use static CRT libraries" OFF)
|
option(STATIC_CRT "Use static CRT libraries" OFF)
|
||||||
|
|
||||||
# Rewrite command line flags to use /MT if necessary
|
# Rewrite command line flags to use /MT if necessary
|
||||||
if(STATIC_CRT)
|
if(STATIC_CRT)
|
||||||
foreach(flag_var
|
foreach(flag_var
|
||||||
@ -47,7 +47,7 @@ endif()
|
|||||||
|
|
||||||
set_target_properties(pugixml PROPERTIES VERSION 1.7 SOVERSION 1)
|
set_target_properties(pugixml PROPERTIES VERSION 1.7 SOVERSION 1)
|
||||||
|
|
||||||
install(TARGETS pugixml EXPORT pugixml-config
|
install(TARGETS pugixml EXPORT pugixml-config
|
||||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||||
|
@ -62,7 +62,7 @@
|
|||||||
*
|
*
|
||||||
* The above copyright notice and this permission notice shall be
|
* The above copyright notice and this permission notice shall be
|
||||||
* included in all copies or substantial portions of the Software.
|
* included in all copies or substantial portions of the Software.
|
||||||
*
|
*
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
790
src/pugixml.cpp
790
src/pugixml.cpp
File diff suppressed because it is too large
Load Diff
@ -133,13 +133,13 @@ namespace pugi
|
|||||||
|
|
||||||
// This flag determines if EOL characters are normalized (converted to #xA) during parsing. This flag is on by default.
|
// This flag determines if EOL characters are normalized (converted to #xA) during parsing. This flag is on by default.
|
||||||
const unsigned int parse_eol = 0x0020;
|
const unsigned int parse_eol = 0x0020;
|
||||||
|
|
||||||
// This flag determines if attribute values are normalized using CDATA normalization rules during parsing. This flag is on by default.
|
// This flag determines if attribute values are normalized using CDATA normalization rules during parsing. This flag is on by default.
|
||||||
const unsigned int parse_wconv_attribute = 0x0040;
|
const unsigned int parse_wconv_attribute = 0x0040;
|
||||||
|
|
||||||
// This flag determines if attribute values are normalized using NMTOKENS normalization rules during parsing. This flag is off by default.
|
// This flag determines if attribute values are normalized using NMTOKENS normalization rules during parsing. This flag is off by default.
|
||||||
const unsigned int parse_wnorm_attribute = 0x0080;
|
const unsigned int parse_wnorm_attribute = 0x0080;
|
||||||
|
|
||||||
// This flag determines if document declaration (node_declaration) is added to the DOM tree. This flag is off by default.
|
// This flag determines if document declaration (node_declaration) is added to the DOM tree. This flag is off by default.
|
||||||
const unsigned int parse_declaration = 0x0100;
|
const unsigned int parse_declaration = 0x0100;
|
||||||
|
|
||||||
@ -189,16 +189,16 @@ namespace pugi
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Formatting flags
|
// Formatting flags
|
||||||
|
|
||||||
// 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.
|
// 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.
|
||||||
const unsigned int format_indent = 0x01;
|
const unsigned int format_indent = 0x01;
|
||||||
|
|
||||||
// Write encoding-specific BOM to the output stream. This flag is off by default.
|
// Write encoding-specific BOM to the output stream. This flag is off by default.
|
||||||
const unsigned int format_write_bom = 0x02;
|
const unsigned int format_write_bom = 0x02;
|
||||||
|
|
||||||
// Use raw output mode (no indentation and no line breaks are written). This flag is off by default.
|
// Use raw output mode (no indentation and no line breaks are written). This flag is off by default.
|
||||||
const unsigned int format_raw = 0x04;
|
const unsigned int format_raw = 0x04;
|
||||||
|
|
||||||
// Omit default XML declaration even if there is no declaration in the document. This flag is off by default.
|
// Omit default XML declaration even if there is no declaration in the document. This flag is off by default.
|
||||||
const unsigned int format_no_declaration = 0x08;
|
const unsigned int format_no_declaration = 0x08;
|
||||||
|
|
||||||
@ -230,7 +230,7 @@ namespace pugi
|
|||||||
class xml_node;
|
class xml_node;
|
||||||
|
|
||||||
class xml_text;
|
class xml_text;
|
||||||
|
|
||||||
#ifndef PUGIXML_NO_XPATH
|
#ifndef PUGIXML_NO_XPATH
|
||||||
class xpath_node;
|
class xpath_node;
|
||||||
class xpath_node_set;
|
class xpath_node_set;
|
||||||
@ -304,13 +304,13 @@ namespace pugi
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
xml_attribute_struct* _attr;
|
xml_attribute_struct* _attr;
|
||||||
|
|
||||||
typedef void (*unspecified_bool_type)(xml_attribute***);
|
typedef void (*unspecified_bool_type)(xml_attribute***);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Default constructor. Constructs an empty attribute.
|
// Default constructor. Constructs an empty attribute.
|
||||||
xml_attribute();
|
xml_attribute();
|
||||||
|
|
||||||
// Constructs attribute from internal pointer
|
// Constructs attribute from internal pointer
|
||||||
explicit xml_attribute(xml_attribute_struct* attr);
|
explicit xml_attribute(xml_attribute_struct* attr);
|
||||||
|
|
||||||
@ -422,7 +422,7 @@ namespace pugi
|
|||||||
|
|
||||||
// Borland C++ workaround
|
// Borland C++ workaround
|
||||||
bool operator!() const;
|
bool operator!() const;
|
||||||
|
|
||||||
// Comparison operators (compares wrapped node pointers)
|
// Comparison operators (compares wrapped node pointers)
|
||||||
bool operator==(const xml_node& r) const;
|
bool operator==(const xml_node& r) const;
|
||||||
bool operator!=(const xml_node& r) const;
|
bool operator!=(const xml_node& r) const;
|
||||||
@ -443,7 +443,7 @@ namespace pugi
|
|||||||
// Get node value, or "" if node is empty or it has no value
|
// Get node value, or "" if node is empty or it has no value
|
||||||
// Note: For <node>text</node> node.value() does not return "text"! Use child_value() or text() methods to access text inside nodes.
|
// Note: For <node>text</node> node.value() does not return "text"! Use child_value() or text() methods to access text inside nodes.
|
||||||
const char_t* value() const;
|
const char_t* value() const;
|
||||||
|
|
||||||
// Get attribute list
|
// Get attribute list
|
||||||
xml_attribute first_attribute() const;
|
xml_attribute first_attribute() const;
|
||||||
xml_attribute last_attribute() const;
|
xml_attribute last_attribute() const;
|
||||||
@ -455,7 +455,7 @@ namespace pugi
|
|||||||
// Get next/previous sibling in the children list of the parent node
|
// Get next/previous sibling in the children list of the parent node
|
||||||
xml_node next_sibling() const;
|
xml_node next_sibling() const;
|
||||||
xml_node previous_sibling() const;
|
xml_node previous_sibling() const;
|
||||||
|
|
||||||
// Get parent node
|
// Get parent node
|
||||||
xml_node parent() const;
|
xml_node parent() const;
|
||||||
|
|
||||||
@ -483,7 +483,7 @@ namespace pugi
|
|||||||
// Set node name/value (returns false if node is empty, there is not enough memory, or node can not have name/value)
|
// Set node name/value (returns false if node is empty, there is not enough memory, or node can not have name/value)
|
||||||
bool set_name(const char_t* rhs);
|
bool set_name(const char_t* rhs);
|
||||||
bool set_value(const char_t* rhs);
|
bool set_value(const char_t* rhs);
|
||||||
|
|
||||||
// Add attribute with specified name. Returns added attribute, or empty attribute on errors.
|
// Add attribute with specified name. Returns added attribute, or empty attribute on errors.
|
||||||
xml_attribute append_attribute(const char_t* name);
|
xml_attribute append_attribute(const char_t* name);
|
||||||
xml_attribute prepend_attribute(const char_t* name);
|
xml_attribute prepend_attribute(const char_t* name);
|
||||||
@ -537,11 +537,11 @@ namespace pugi
|
|||||||
template <typename Predicate> xml_attribute find_attribute(Predicate pred) const
|
template <typename Predicate> xml_attribute find_attribute(Predicate pred) const
|
||||||
{
|
{
|
||||||
if (!_root) return xml_attribute();
|
if (!_root) return xml_attribute();
|
||||||
|
|
||||||
for (xml_attribute attrib = first_attribute(); attrib; attrib = attrib.next_attribute())
|
for (xml_attribute attrib = first_attribute(); attrib; attrib = attrib.next_attribute())
|
||||||
if (pred(attrib))
|
if (pred(attrib))
|
||||||
return attrib;
|
return attrib;
|
||||||
|
|
||||||
return xml_attribute();
|
return xml_attribute();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -549,11 +549,11 @@ namespace pugi
|
|||||||
template <typename Predicate> xml_node find_child(Predicate pred) const
|
template <typename Predicate> xml_node find_child(Predicate pred) const
|
||||||
{
|
{
|
||||||
if (!_root) return xml_node();
|
if (!_root) return xml_node();
|
||||||
|
|
||||||
for (xml_node node = first_child(); node; node = node.next_sibling())
|
for (xml_node node = first_child(); node; node = node.next_sibling())
|
||||||
if (pred(node))
|
if (pred(node))
|
||||||
return node;
|
return node;
|
||||||
|
|
||||||
return xml_node();
|
return xml_node();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -563,7 +563,7 @@ namespace pugi
|
|||||||
if (!_root) return xml_node();
|
if (!_root) return xml_node();
|
||||||
|
|
||||||
xml_node cur = first_child();
|
xml_node cur = first_child();
|
||||||
|
|
||||||
while (cur._root && cur._root != _root)
|
while (cur._root && cur._root != _root)
|
||||||
{
|
{
|
||||||
if (pred(cur)) return cur;
|
if (pred(cur)) return cur;
|
||||||
@ -595,7 +595,7 @@ namespace pugi
|
|||||||
|
|
||||||
// Recursively traverse subtree with xml_tree_walker
|
// Recursively traverse subtree with xml_tree_walker
|
||||||
bool traverse(xml_tree_walker& walker);
|
bool traverse(xml_tree_walker& walker);
|
||||||
|
|
||||||
#ifndef PUGIXML_NO_XPATH
|
#ifndef PUGIXML_NO_XPATH
|
||||||
// Select single node by evaluating XPath query. Returns first node from the resulting node set.
|
// Select single node by evaluating XPath query. Returns first node from the resulting node set.
|
||||||
xpath_node select_node(const char_t* query, xpath_variable_set* variables = 0) const;
|
xpath_node select_node(const char_t* query, xpath_variable_set* variables = 0) const;
|
||||||
@ -610,7 +610,7 @@ namespace pugi
|
|||||||
xpath_node select_single_node(const xpath_query& query) const;
|
xpath_node select_single_node(const xpath_query& query) const;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Print subtree using a writer object
|
// Print subtree using a writer object
|
||||||
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;
|
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;
|
||||||
|
|
||||||
@ -872,11 +872,11 @@ namespace pugi
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
int _depth;
|
int _depth;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Get current traversal depth
|
// Get current traversal depth
|
||||||
int depth() const;
|
int depth() const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
xml_tree_walker();
|
xml_tree_walker();
|
||||||
virtual ~xml_tree_walker();
|
virtual ~xml_tree_walker();
|
||||||
@ -947,7 +947,7 @@ namespace pugi
|
|||||||
char_t* _buffer;
|
char_t* _buffer;
|
||||||
|
|
||||||
char _memory[192];
|
char _memory[192];
|
||||||
|
|
||||||
// Non-copyable semantics
|
// Non-copyable semantics
|
||||||
xml_document(const xml_document&);
|
xml_document(const xml_document&);
|
||||||
xml_document& operator=(const xml_document&);
|
xml_document& operator=(const xml_document&);
|
||||||
@ -1056,7 +1056,7 @@ namespace pugi
|
|||||||
// Non-copyable semantics
|
// Non-copyable semantics
|
||||||
xpath_variable(const xpath_variable&);
|
xpath_variable(const xpath_variable&);
|
||||||
xpath_variable& operator=(const xpath_variable&);
|
xpath_variable& operator=(const xpath_variable&);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Get variable name
|
// Get variable name
|
||||||
const char_t* name() const;
|
const char_t* name() const;
|
||||||
@ -1152,21 +1152,21 @@ namespace pugi
|
|||||||
|
|
||||||
// Get query expression return type
|
// Get query expression return type
|
||||||
xpath_value_type return_type() const;
|
xpath_value_type return_type() const;
|
||||||
|
|
||||||
// Evaluate expression as boolean value in the specified context; performs type conversion if necessary.
|
// Evaluate expression as boolean value in the specified context; performs type conversion if necessary.
|
||||||
// If PUGIXML_NO_EXCEPTIONS is not defined, throws std::bad_alloc on out of memory errors.
|
// If PUGIXML_NO_EXCEPTIONS is not defined, throws std::bad_alloc on out of memory errors.
|
||||||
bool evaluate_boolean(const xpath_node& n) const;
|
bool evaluate_boolean(const xpath_node& n) const;
|
||||||
|
|
||||||
// Evaluate expression as double value in the specified context; performs type conversion if necessary.
|
// Evaluate expression as double value in the specified context; performs type conversion if necessary.
|
||||||
// If PUGIXML_NO_EXCEPTIONS is not defined, throws std::bad_alloc on out of memory errors.
|
// If PUGIXML_NO_EXCEPTIONS is not defined, throws std::bad_alloc on out of memory errors.
|
||||||
double evaluate_number(const xpath_node& n) const;
|
double evaluate_number(const xpath_node& n) const;
|
||||||
|
|
||||||
#ifndef PUGIXML_NO_STL
|
#ifndef PUGIXML_NO_STL
|
||||||
// Evaluate expression as string value in the specified context; performs type conversion if necessary.
|
// Evaluate expression as string value in the specified context; performs type conversion if necessary.
|
||||||
// If PUGIXML_NO_EXCEPTIONS is not defined, throws std::bad_alloc on out of memory errors.
|
// If PUGIXML_NO_EXCEPTIONS is not defined, throws std::bad_alloc on out of memory errors.
|
||||||
string_t evaluate_string(const xpath_node& n) const;
|
string_t evaluate_string(const xpath_node& n) const;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Evaluate expression as string value in the specified context; performs type conversion if necessary.
|
// Evaluate expression as string value in the specified context; performs type conversion if necessary.
|
||||||
// At most capacity characters are written to the destination buffer, full result size is returned (includes terminating zero).
|
// At most capacity characters are written to the destination buffer, full result size is returned (includes terminating zero).
|
||||||
// If PUGIXML_NO_EXCEPTIONS is not defined, throws std::bad_alloc on out of memory errors.
|
// If PUGIXML_NO_EXCEPTIONS is not defined, throws std::bad_alloc on out of memory errors.
|
||||||
@ -1193,7 +1193,7 @@ namespace pugi
|
|||||||
// Borland C++ workaround
|
// Borland C++ workaround
|
||||||
bool operator!() const;
|
bool operator!() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef PUGIXML_NO_EXCEPTIONS
|
#ifndef PUGIXML_NO_EXCEPTIONS
|
||||||
// XPath exception class
|
// XPath exception class
|
||||||
class PUGIXML_CLASS xpath_exception: public std::exception
|
class PUGIXML_CLASS xpath_exception: public std::exception
|
||||||
@ -1212,20 +1212,20 @@ namespace pugi
|
|||||||
const xpath_parse_result& result() const;
|
const xpath_parse_result& result() const;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// XPath node class (either xml_node or xml_attribute)
|
// XPath node class (either xml_node or xml_attribute)
|
||||||
class PUGIXML_CLASS xpath_node
|
class PUGIXML_CLASS xpath_node
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
xml_node _node;
|
xml_node _node;
|
||||||
xml_attribute _attribute;
|
xml_attribute _attribute;
|
||||||
|
|
||||||
typedef void (*unspecified_bool_type)(xpath_node***);
|
typedef void (*unspecified_bool_type)(xpath_node***);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Default constructor; constructs empty XPath node
|
// Default constructor; constructs empty XPath node
|
||||||
xpath_node();
|
xpath_node();
|
||||||
|
|
||||||
// Construct XPath node from XML node/attribute
|
// Construct XPath node from XML node/attribute
|
||||||
xpath_node(const xml_node& node);
|
xpath_node(const xml_node& node);
|
||||||
xpath_node(const xml_attribute& attribute, const xml_node& parent);
|
xpath_node(const xml_attribute& attribute, const xml_node& parent);
|
||||||
@ -1233,13 +1233,13 @@ namespace pugi
|
|||||||
// Get node/attribute, if any
|
// Get node/attribute, if any
|
||||||
xml_node node() const;
|
xml_node node() const;
|
||||||
xml_attribute attribute() const;
|
xml_attribute attribute() const;
|
||||||
|
|
||||||
// Get parent of contained node/attribute
|
// Get parent of contained node/attribute
|
||||||
xml_node parent() const;
|
xml_node parent() const;
|
||||||
|
|
||||||
// Safe bool conversion operator
|
// Safe bool conversion operator
|
||||||
operator unspecified_bool_type() const;
|
operator unspecified_bool_type() const;
|
||||||
|
|
||||||
// Borland C++ workaround
|
// Borland C++ workaround
|
||||||
bool operator!() const;
|
bool operator!() const;
|
||||||
|
|
||||||
@ -1265,13 +1265,13 @@ namespace pugi
|
|||||||
type_sorted, // Sorted by document order (ascending)
|
type_sorted, // Sorted by document order (ascending)
|
||||||
type_sorted_reverse // Sorted by document order (descending)
|
type_sorted_reverse // Sorted by document order (descending)
|
||||||
};
|
};
|
||||||
|
|
||||||
// Constant iterator type
|
// Constant iterator type
|
||||||
typedef const xpath_node* const_iterator;
|
typedef const xpath_node* const_iterator;
|
||||||
|
|
||||||
// We define non-constant iterator to be the same as constant iterator so that various generic algorithms (i.e. boost foreach) work
|
// We define non-constant iterator to be the same as constant iterator so that various generic algorithms (i.e. boost foreach) work
|
||||||
typedef const xpath_node* iterator;
|
typedef const xpath_node* iterator;
|
||||||
|
|
||||||
// Default constructor. Constructs empty set.
|
// Default constructor. Constructs empty set.
|
||||||
xpath_node_set();
|
xpath_node_set();
|
||||||
|
|
||||||
@ -1280,7 +1280,7 @@ namespace pugi
|
|||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~xpath_node_set();
|
~xpath_node_set();
|
||||||
|
|
||||||
// Copy constructor/assignment operator
|
// Copy constructor/assignment operator
|
||||||
xpath_node_set(const xpath_node_set& ns);
|
xpath_node_set(const xpath_node_set& ns);
|
||||||
xpath_node_set& operator=(const xpath_node_set& ns);
|
xpath_node_set& operator=(const xpath_node_set& ns);
|
||||||
@ -1293,31 +1293,31 @@ namespace pugi
|
|||||||
|
|
||||||
// Get collection type
|
// Get collection type
|
||||||
type_t type() const;
|
type_t type() const;
|
||||||
|
|
||||||
// Get collection size
|
// Get collection size
|
||||||
size_t size() const;
|
size_t size() const;
|
||||||
|
|
||||||
// Indexing operator
|
// Indexing operator
|
||||||
const xpath_node& operator[](size_t index) const;
|
const xpath_node& operator[](size_t index) const;
|
||||||
|
|
||||||
// Collection iterators
|
// Collection iterators
|
||||||
const_iterator begin() const;
|
const_iterator begin() const;
|
||||||
const_iterator end() const;
|
const_iterator end() const;
|
||||||
|
|
||||||
// Sort the collection in ascending/descending order by document order
|
// Sort the collection in ascending/descending order by document order
|
||||||
void sort(bool reverse = false);
|
void sort(bool reverse = false);
|
||||||
|
|
||||||
// Get first node in the collection by document order
|
// Get first node in the collection by document order
|
||||||
xpath_node first() const;
|
xpath_node first() const;
|
||||||
|
|
||||||
// Check if collection is empty
|
// Check if collection is empty
|
||||||
bool empty() const;
|
bool empty() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
type_t _type;
|
type_t _type;
|
||||||
|
|
||||||
xpath_node _storage;
|
xpath_node _storage;
|
||||||
|
|
||||||
xpath_node* _begin;
|
xpath_node* _begin;
|
||||||
xpath_node* _end;
|
xpath_node* _end;
|
||||||
|
|
||||||
@ -1330,7 +1330,7 @@ namespace pugi
|
|||||||
// Convert wide string to UTF8
|
// Convert wide string to UTF8
|
||||||
std::basic_string<char, std::char_traits<char>, std::allocator<char> > PUGIXML_FUNCTION as_utf8(const wchar_t* str);
|
std::basic_string<char, std::char_traits<char>, std::allocator<char> > PUGIXML_FUNCTION as_utf8(const wchar_t* str);
|
||||||
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);
|
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);
|
||||||
|
|
||||||
// Convert UTF8 to wide string
|
// Convert UTF8 to wide string
|
||||||
std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > PUGIXML_FUNCTION as_wide(const char* str);
|
std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > PUGIXML_FUNCTION as_wide(const char* str);
|
||||||
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);
|
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);
|
||||||
@ -1338,13 +1338,13 @@ namespace pugi
|
|||||||
|
|
||||||
// Memory allocation function interface; returns pointer to allocated memory or NULL on failure
|
// Memory allocation function interface; returns pointer to allocated memory or NULL on failure
|
||||||
typedef void* (*allocation_function)(size_t size);
|
typedef void* (*allocation_function)(size_t size);
|
||||||
|
|
||||||
// Memory deallocation function interface
|
// Memory deallocation function interface
|
||||||
typedef void (*deallocation_function)(void* ptr);
|
typedef void (*deallocation_function)(void* ptr);
|
||||||
|
|
||||||
// Override default memory management functions. All subsequent allocations/deallocations will be performed via supplied functions.
|
// Override default memory management functions. All subsequent allocations/deallocations will be performed via supplied functions.
|
||||||
void PUGIXML_FUNCTION set_memory_management_functions(allocation_function allocate, deallocation_function deallocate);
|
void PUGIXML_FUNCTION set_memory_management_functions(allocation_function allocate, deallocation_function deallocate);
|
||||||
|
|
||||||
// Get current memory management functions
|
// Get current memory management functions
|
||||||
allocation_function PUGIXML_FUNCTION get_memory_allocation_function();
|
allocation_function PUGIXML_FUNCTION get_memory_allocation_function();
|
||||||
deallocation_function PUGIXML_FUNCTION get_memory_deallocation_function();
|
deallocation_function PUGIXML_FUNCTION get_memory_deallocation_function();
|
||||||
@ -1393,7 +1393,7 @@ namespace std
|
|||||||
*
|
*
|
||||||
* The above copyright notice and this permission notice shall be
|
* The above copyright notice and this permission notice shall be
|
||||||
* included in all copies or substantial portions of the Software.
|
* included in all copies or substantial portions of the Software.
|
||||||
*
|
*
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
@ -45,7 +45,7 @@ static void* custom_allocate(size_t size)
|
|||||||
|
|
||||||
g_memory_total_size += memory_size(ptr);
|
g_memory_total_size += memory_size(ptr);
|
||||||
g_memory_total_count++;
|
g_memory_total_count++;
|
||||||
|
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -68,7 +68,7 @@ static void custom_deallocate(void* ptr)
|
|||||||
|
|
||||||
g_memory_total_size -= memory_size(ptr);
|
g_memory_total_size -= memory_size(ptr);
|
||||||
g_memory_total_count--;
|
g_memory_total_count--;
|
||||||
|
|
||||||
memory_deallocate(ptr);
|
memory_deallocate(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,9 +105,9 @@ static bool run_test(test_runner* test, const char* test_name, pugi::allocation_
|
|||||||
g_memory_fail_triggered = false;
|
g_memory_fail_triggered = false;
|
||||||
test_runner::_memory_fail_threshold = 0;
|
test_runner::_memory_fail_threshold = 0;
|
||||||
test_runner::_memory_fail_triggered = false;
|
test_runner::_memory_fail_triggered = false;
|
||||||
|
|
||||||
pugi::set_memory_management_functions(allocate, custom_deallocate);
|
pugi::set_memory_management_functions(allocate, custom_deallocate);
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
# pragma warning(push)
|
# pragma warning(push)
|
||||||
# pragma warning(disable: 4611) // interaction between _setjmp and C++ object destruction is non-portable
|
# pragma warning(disable: 4611) // interaction between _setjmp and C++ object destruction is non-portable
|
||||||
@ -115,7 +115,7 @@ static bool run_test(test_runner* test, const char* test_name, pugi::allocation_
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
volatile int result = setjmp(test_runner::_failure_buffer);
|
volatile int result = setjmp(test_runner::_failure_buffer);
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
# pragma warning(pop)
|
# pragma warning(pop)
|
||||||
#endif
|
#endif
|
||||||
@ -177,7 +177,7 @@ int main(int, char** argv)
|
|||||||
temp.erase((slash != std::string::npos) ? slash + 1 : 0);
|
temp.erase((slash != std::string::npos) ? slash + 1 : 0);
|
||||||
|
|
||||||
test_runner::_temp_path = temp.c_str();
|
test_runner::_temp_path = temp.c_str();
|
||||||
|
|
||||||
replace_memory_management();
|
replace_memory_management();
|
||||||
|
|
||||||
unsigned int total = 0;
|
unsigned int total = 0;
|
||||||
|
@ -157,7 +157,7 @@ struct dummy_fixture {};
|
|||||||
#if (defined(_MSC_VER) && _MSC_VER == 1200) || (defined(__INTEL_COMPILER) && __INTEL_COMPILER == 800) || defined(__BORLANDC__)
|
#if (defined(_MSC_VER) && _MSC_VER == 1200) || (defined(__INTEL_COMPILER) && __INTEL_COMPILER == 800) || defined(__BORLANDC__)
|
||||||
// NaN comparison on MSVC6 is incorrect, see http://www.nabble.com/assertDoubleEquals,-NaN---Microsoft-Visual-Studio-6-td9137859.html
|
// NaN comparison on MSVC6 is incorrect, see http://www.nabble.com/assertDoubleEquals,-NaN---Microsoft-Visual-Studio-6-td9137859.html
|
||||||
// IC8 and BCC are also affected by the same bug
|
// IC8 and BCC are also affected by the same bug
|
||||||
# define MSVC6_NAN_BUG
|
# define MSVC6_NAN_BUG
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
inline wchar_t wchar_cast(unsigned int value)
|
inline wchar_t wchar_cast(unsigned int value)
|
||||||
|
@ -109,7 +109,7 @@ TEST(document_load_stream_error)
|
|||||||
|
|
||||||
std::ifstream fs("filedoesnotexist");
|
std::ifstream fs("filedoesnotexist");
|
||||||
CHECK(doc.load(fs).status == status_io_error);
|
CHECK(doc.load(fs).status == status_io_error);
|
||||||
|
|
||||||
std::istringstream iss("<node/>");
|
std::istringstream iss("<node/>");
|
||||||
test_runner::_memory_fail_threshold = 1;
|
test_runner::_memory_fail_threshold = 1;
|
||||||
CHECK_ALLOC_FAIL(CHECK(doc.load(iss).status == status_out_of_memory));
|
CHECK_ALLOC_FAIL(CHECK(doc.load(iss).status == status_out_of_memory));
|
||||||
@ -499,7 +499,7 @@ TEST_XML(document_save_declaration_latin1, "<node/>")
|
|||||||
struct temp_file
|
struct temp_file
|
||||||
{
|
{
|
||||||
char path[512];
|
char path[512];
|
||||||
|
|
||||||
temp_file()
|
temp_file()
|
||||||
{
|
{
|
||||||
static int index = 0;
|
static int index = 0;
|
||||||
|
@ -74,7 +74,7 @@ TEST_XML(dom_attr_set_value, "<node/>")
|
|||||||
TEST_XML(dom_attr_assign_llong, "<node/>")
|
TEST_XML(dom_attr_assign_llong, "<node/>")
|
||||||
{
|
{
|
||||||
xml_node node = doc.child(STR("node"));
|
xml_node node = doc.child(STR("node"));
|
||||||
|
|
||||||
node.append_attribute(STR("attr1")) = -9223372036854775807ll;
|
node.append_attribute(STR("attr1")) = -9223372036854775807ll;
|
||||||
node.append_attribute(STR("attr2")) = -9223372036854775807ll - 1;
|
node.append_attribute(STR("attr2")) = -9223372036854775807ll - 1;
|
||||||
xml_attribute() = -9223372036854775807ll - 1;
|
xml_attribute() = -9223372036854775807ll - 1;
|
||||||
@ -89,7 +89,7 @@ TEST_XML(dom_attr_assign_llong, "<node/>")
|
|||||||
TEST_XML(dom_attr_set_value_llong, "<node/>")
|
TEST_XML(dom_attr_set_value_llong, "<node/>")
|
||||||
{
|
{
|
||||||
xml_node node = doc.child(STR("node"));
|
xml_node node = doc.child(STR("node"));
|
||||||
|
|
||||||
CHECK(node.append_attribute(STR("attr1")).set_value(-9223372036854775807ll));
|
CHECK(node.append_attribute(STR("attr1")).set_value(-9223372036854775807ll));
|
||||||
CHECK(node.append_attribute(STR("attr2")).set_value(-9223372036854775807ll - 1));
|
CHECK(node.append_attribute(STR("attr2")).set_value(-9223372036854775807ll - 1));
|
||||||
CHECK(!xml_attribute().set_value(-9223372036854775807ll - 1));
|
CHECK(!xml_attribute().set_value(-9223372036854775807ll - 1));
|
||||||
@ -158,7 +158,7 @@ TEST_XML(dom_node_prepend_attribute, "<node><child/></node>")
|
|||||||
{
|
{
|
||||||
CHECK(xml_node().prepend_attribute(STR("a")) == xml_attribute());
|
CHECK(xml_node().prepend_attribute(STR("a")) == xml_attribute());
|
||||||
CHECK(doc.prepend_attribute(STR("a")) == xml_attribute());
|
CHECK(doc.prepend_attribute(STR("a")) == xml_attribute());
|
||||||
|
|
||||||
xml_attribute a1 = doc.child(STR("node")).prepend_attribute(STR("a1"));
|
xml_attribute a1 = doc.child(STR("node")).prepend_attribute(STR("a1"));
|
||||||
CHECK(a1);
|
CHECK(a1);
|
||||||
a1 = STR("v1");
|
a1 = STR("v1");
|
||||||
@ -178,7 +178,7 @@ TEST_XML(dom_node_append_attribute, "<node><child/></node>")
|
|||||||
{
|
{
|
||||||
CHECK(xml_node().append_attribute(STR("a")) == xml_attribute());
|
CHECK(xml_node().append_attribute(STR("a")) == xml_attribute());
|
||||||
CHECK(doc.append_attribute(STR("a")) == xml_attribute());
|
CHECK(doc.append_attribute(STR("a")) == xml_attribute());
|
||||||
|
|
||||||
xml_attribute a1 = doc.child(STR("node")).append_attribute(STR("a1"));
|
xml_attribute a1 = doc.child(STR("node")).append_attribute(STR("a1"));
|
||||||
CHECK(a1);
|
CHECK(a1);
|
||||||
a1 = STR("v1");
|
a1 = STR("v1");
|
||||||
@ -206,7 +206,7 @@ TEST_XML(dom_node_insert_attribute_after, "<node a1='v1'><child a2='v2'/></node>
|
|||||||
|
|
||||||
CHECK(node.insert_attribute_after(STR("a"), xml_attribute()) == xml_attribute());
|
CHECK(node.insert_attribute_after(STR("a"), xml_attribute()) == xml_attribute());
|
||||||
CHECK(node.insert_attribute_after(STR("a"), a2) == xml_attribute());
|
CHECK(node.insert_attribute_after(STR("a"), a2) == xml_attribute());
|
||||||
|
|
||||||
xml_attribute a3 = node.insert_attribute_after(STR("a3"), a1);
|
xml_attribute a3 = node.insert_attribute_after(STR("a3"), a1);
|
||||||
CHECK(a3 && a3 != a2 && a3 != a1);
|
CHECK(a3 && a3 != a2 && a3 != a1);
|
||||||
a3 = STR("v3");
|
a3 = STR("v3");
|
||||||
@ -236,7 +236,7 @@ TEST_XML(dom_node_insert_attribute_before, "<node a1='v1'><child a2='v2'/></node
|
|||||||
|
|
||||||
CHECK(node.insert_attribute_before(STR("a"), xml_attribute()) == xml_attribute());
|
CHECK(node.insert_attribute_before(STR("a"), xml_attribute()) == xml_attribute());
|
||||||
CHECK(node.insert_attribute_before(STR("a"), a2) == xml_attribute());
|
CHECK(node.insert_attribute_before(STR("a"), a2) == xml_attribute());
|
||||||
|
|
||||||
xml_attribute a3 = node.insert_attribute_before(STR("a3"), a1);
|
xml_attribute a3 = node.insert_attribute_before(STR("a3"), a1);
|
||||||
CHECK(a3 && a3 != a2 && a3 != a1);
|
CHECK(a3 && a3 != a2 && a3 != a1);
|
||||||
a3 = STR("v3");
|
a3 = STR("v3");
|
||||||
@ -260,7 +260,7 @@ TEST_XML(dom_node_prepend_copy_attribute, "<node a1='v1'><child a2='v2'/><child/
|
|||||||
CHECK(xml_node().prepend_copy(doc.child(STR("node")).attribute(STR("a1"))) == xml_attribute());
|
CHECK(xml_node().prepend_copy(doc.child(STR("node")).attribute(STR("a1"))) == xml_attribute());
|
||||||
CHECK(doc.prepend_copy(doc.child(STR("node")).attribute(STR("a1"))) == xml_attribute());
|
CHECK(doc.prepend_copy(doc.child(STR("node")).attribute(STR("a1"))) == xml_attribute());
|
||||||
CHECK(doc.child(STR("node")).prepend_copy(xml_attribute()) == xml_attribute());
|
CHECK(doc.child(STR("node")).prepend_copy(xml_attribute()) == xml_attribute());
|
||||||
|
|
||||||
xml_node node = doc.child(STR("node"));
|
xml_node node = doc.child(STR("node"));
|
||||||
xml_node child = node.child(STR("child"));
|
xml_node child = node.child(STR("child"));
|
||||||
|
|
||||||
@ -280,13 +280,13 @@ TEST_XML(dom_node_prepend_copy_attribute, "<node a1='v1'><child a2='v2'/><child/
|
|||||||
|
|
||||||
a3.set_name(STR("a3"));
|
a3.set_name(STR("a3"));
|
||||||
a3 = STR("v3");
|
a3 = STR("v3");
|
||||||
|
|
||||||
a4.set_name(STR("a4"));
|
a4.set_name(STR("a4"));
|
||||||
a4 = STR("v4");
|
a4 = STR("v4");
|
||||||
|
|
||||||
a5.set_name(STR("a5"));
|
a5.set_name(STR("a5"));
|
||||||
a5 = STR("v5");
|
a5 = STR("v5");
|
||||||
|
|
||||||
CHECK_NODE(doc, STR("<node a4=\"v4\" a3=\"v3\" a1=\"v1\"><child a2=\"v2\" /><child a5=\"v5\" /></node>"));
|
CHECK_NODE(doc, STR("<node a4=\"v4\" a3=\"v3\" a1=\"v1\"><child a2=\"v2\" /><child a5=\"v5\" /></node>"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -296,7 +296,7 @@ TEST_XML(dom_node_append_copy_attribute, "<node a1='v1'><child a2='v2'/><child/>
|
|||||||
CHECK(xml_node().append_copy(doc.child(STR("node")).attribute(STR("a1"))) == xml_attribute());
|
CHECK(xml_node().append_copy(doc.child(STR("node")).attribute(STR("a1"))) == xml_attribute());
|
||||||
CHECK(doc.append_copy(doc.child(STR("node")).attribute(STR("a1"))) == xml_attribute());
|
CHECK(doc.append_copy(doc.child(STR("node")).attribute(STR("a1"))) == xml_attribute());
|
||||||
CHECK(doc.child(STR("node")).append_copy(xml_attribute()) == xml_attribute());
|
CHECK(doc.child(STR("node")).append_copy(xml_attribute()) == xml_attribute());
|
||||||
|
|
||||||
xml_node node = doc.child(STR("node"));
|
xml_node node = doc.child(STR("node"));
|
||||||
xml_node child = node.child(STR("child"));
|
xml_node child = node.child(STR("child"));
|
||||||
|
|
||||||
@ -316,13 +316,13 @@ TEST_XML(dom_node_append_copy_attribute, "<node a1='v1'><child a2='v2'/><child/>
|
|||||||
|
|
||||||
a3.set_name(STR("a3"));
|
a3.set_name(STR("a3"));
|
||||||
a3 = STR("v3");
|
a3 = STR("v3");
|
||||||
|
|
||||||
a4.set_name(STR("a4"));
|
a4.set_name(STR("a4"));
|
||||||
a4 = STR("v4");
|
a4 = STR("v4");
|
||||||
|
|
||||||
a5.set_name(STR("a5"));
|
a5.set_name(STR("a5"));
|
||||||
a5 = STR("v5");
|
a5 = STR("v5");
|
||||||
|
|
||||||
CHECK_NODE(doc, STR("<node a1=\"v1\" a3=\"v3\" a4=\"v4\"><child a2=\"v2\" /><child a5=\"v5\" /></node>"));
|
CHECK_NODE(doc, STR("<node a1=\"v1\" a3=\"v3\" a4=\"v4\"><child a2=\"v2\" /><child a5=\"v5\" /></node>"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -339,7 +339,7 @@ TEST_XML(dom_node_insert_copy_after_attribute, "<node a1='v1'><child a2='v2'/></
|
|||||||
CHECK(node.insert_copy_after(a1, xml_attribute()) == xml_attribute());
|
CHECK(node.insert_copy_after(a1, xml_attribute()) == xml_attribute());
|
||||||
CHECK(node.insert_copy_after(xml_attribute(), a1) == xml_attribute());
|
CHECK(node.insert_copy_after(xml_attribute(), a1) == xml_attribute());
|
||||||
CHECK(node.insert_copy_after(a2, a2) == xml_attribute());
|
CHECK(node.insert_copy_after(a2, a2) == xml_attribute());
|
||||||
|
|
||||||
xml_attribute a3 = node.insert_copy_after(a1, a1);
|
xml_attribute a3 = node.insert_copy_after(a1, a1);
|
||||||
CHECK(a3 && a3 != a2 && a3 != a1);
|
CHECK(a3 && a3 != a2 && a3 != a1);
|
||||||
|
|
||||||
@ -355,13 +355,13 @@ TEST_XML(dom_node_insert_copy_after_attribute, "<node a1='v1'><child a2='v2'/></
|
|||||||
|
|
||||||
a3.set_name(STR("a3"));
|
a3.set_name(STR("a3"));
|
||||||
a3 = STR("v3");
|
a3 = STR("v3");
|
||||||
|
|
||||||
a4.set_name(STR("a4"));
|
a4.set_name(STR("a4"));
|
||||||
a4 = STR("v4");
|
a4 = STR("v4");
|
||||||
|
|
||||||
a5.set_name(STR("a5"));
|
a5.set_name(STR("a5"));
|
||||||
a5 = STR("v5");
|
a5 = STR("v5");
|
||||||
|
|
||||||
CHECK_NODE(doc, STR("<node a1=\"v1\" a5=\"v5\" a4=\"v4\" a3=\"v3\"><child a2=\"v2\" /></node>"));
|
CHECK_NODE(doc, STR("<node a1=\"v1\" a5=\"v5\" a4=\"v4\" a3=\"v3\"><child a2=\"v2\" /></node>"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -378,7 +378,7 @@ TEST_XML(dom_node_insert_copy_before_attribute, "<node a1='v1'><child a2='v2'/><
|
|||||||
CHECK(node.insert_copy_before(a1, xml_attribute()) == xml_attribute());
|
CHECK(node.insert_copy_before(a1, xml_attribute()) == xml_attribute());
|
||||||
CHECK(node.insert_copy_before(xml_attribute(), a1) == xml_attribute());
|
CHECK(node.insert_copy_before(xml_attribute(), a1) == xml_attribute());
|
||||||
CHECK(node.insert_copy_before(a2, a2) == xml_attribute());
|
CHECK(node.insert_copy_before(a2, a2) == xml_attribute());
|
||||||
|
|
||||||
xml_attribute a3 = node.insert_copy_before(a1, a1);
|
xml_attribute a3 = node.insert_copy_before(a1, a1);
|
||||||
CHECK(a3 && a3 != a2 && a3 != a1);
|
CHECK(a3 && a3 != a2 && a3 != a1);
|
||||||
|
|
||||||
@ -394,13 +394,13 @@ TEST_XML(dom_node_insert_copy_before_attribute, "<node a1='v1'><child a2='v2'/><
|
|||||||
|
|
||||||
a3.set_name(STR("a3"));
|
a3.set_name(STR("a3"));
|
||||||
a3 = STR("v3");
|
a3 = STR("v3");
|
||||||
|
|
||||||
a4.set_name(STR("a4"));
|
a4.set_name(STR("a4"));
|
||||||
a4 = STR("v4");
|
a4 = STR("v4");
|
||||||
|
|
||||||
a5.set_name(STR("a5"));
|
a5.set_name(STR("a5"));
|
||||||
a5 = STR("v5");
|
a5 = STR("v5");
|
||||||
|
|
||||||
CHECK_NODE(doc, STR("<node a3=\"v3\" a4=\"v4\" a5=\"v5\" a1=\"v1\"><child a2=\"v2\" /></node>"));
|
CHECK_NODE(doc, STR("<node a3=\"v3\" a4=\"v4\" a5=\"v5\" a1=\"v1\"><child a2=\"v2\" /></node>"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -408,7 +408,7 @@ TEST_XML(dom_node_remove_attribute, "<node a1='v1' a2='v2' a3='v3'><child a4='v4
|
|||||||
{
|
{
|
||||||
CHECK(!xml_node().remove_attribute(STR("a")));
|
CHECK(!xml_node().remove_attribute(STR("a")));
|
||||||
CHECK(!xml_node().remove_attribute(xml_attribute()));
|
CHECK(!xml_node().remove_attribute(xml_attribute()));
|
||||||
|
|
||||||
xml_node node = doc.child(STR("node"));
|
xml_node node = doc.child(STR("node"));
|
||||||
xml_node child = node.child(STR("child"));
|
xml_node child = node.child(STR("child"));
|
||||||
|
|
||||||
@ -431,7 +431,7 @@ TEST_XML(dom_node_prepend_child, "<node>foo<child/></node>")
|
|||||||
CHECK(doc.child(STR("node")).first_child().prepend_child() == xml_node());
|
CHECK(doc.child(STR("node")).first_child().prepend_child() == xml_node());
|
||||||
CHECK(doc.prepend_child(node_document) == xml_node());
|
CHECK(doc.prepend_child(node_document) == xml_node());
|
||||||
CHECK(doc.prepend_child(node_null) == xml_node());
|
CHECK(doc.prepend_child(node_null) == xml_node());
|
||||||
|
|
||||||
xml_node n1 = doc.child(STR("node")).prepend_child();
|
xml_node n1 = doc.child(STR("node")).prepend_child();
|
||||||
CHECK(n1);
|
CHECK(n1);
|
||||||
CHECK(n1.set_name(STR("n1")));
|
CHECK(n1.set_name(STR("n1")));
|
||||||
@ -443,7 +443,7 @@ TEST_XML(dom_node_prepend_child, "<node>foo<child/></node>")
|
|||||||
xml_node n3 = doc.child(STR("node")).child(STR("child")).prepend_child(node_pcdata);
|
xml_node n3 = doc.child(STR("node")).child(STR("child")).prepend_child(node_pcdata);
|
||||||
CHECK(n3 && n1 != n3 && n2 != n3);
|
CHECK(n3 && n1 != n3 && n2 != n3);
|
||||||
CHECK(n3.set_value(STR("n3")));
|
CHECK(n3.set_value(STR("n3")));
|
||||||
|
|
||||||
xml_node n4 = doc.prepend_child(node_comment);
|
xml_node n4 = doc.prepend_child(node_comment);
|
||||||
CHECK(n4 && n1 != n4 && n2 != n4 && n3 != n4);
|
CHECK(n4 && n1 != n4 && n2 != n4 && n3 != n4);
|
||||||
CHECK(n4.set_value(STR("n4")));
|
CHECK(n4.set_value(STR("n4")));
|
||||||
@ -457,7 +457,7 @@ TEST_XML(dom_node_append_child, "<node>foo<child/></node>")
|
|||||||
CHECK(doc.child(STR("node")).first_child().append_child() == xml_node());
|
CHECK(doc.child(STR("node")).first_child().append_child() == xml_node());
|
||||||
CHECK(doc.append_child(node_document) == xml_node());
|
CHECK(doc.append_child(node_document) == xml_node());
|
||||||
CHECK(doc.append_child(node_null) == xml_node());
|
CHECK(doc.append_child(node_null) == xml_node());
|
||||||
|
|
||||||
xml_node n1 = doc.child(STR("node")).append_child();
|
xml_node n1 = doc.child(STR("node")).append_child();
|
||||||
CHECK(n1);
|
CHECK(n1);
|
||||||
CHECK(n1.set_name(STR("n1")));
|
CHECK(n1.set_name(STR("n1")));
|
||||||
@ -469,7 +469,7 @@ TEST_XML(dom_node_append_child, "<node>foo<child/></node>")
|
|||||||
xml_node n3 = doc.child(STR("node")).child(STR("child")).append_child(node_pcdata);
|
xml_node n3 = doc.child(STR("node")).child(STR("child")).append_child(node_pcdata);
|
||||||
CHECK(n3 && n1 != n3 && n2 != n3);
|
CHECK(n3 && n1 != n3 && n2 != n3);
|
||||||
CHECK(n3.set_value(STR("n3")));
|
CHECK(n3.set_value(STR("n3")));
|
||||||
|
|
||||||
xml_node n4 = doc.append_child(node_comment);
|
xml_node n4 = doc.append_child(node_comment);
|
||||||
CHECK(n4 && n1 != n4 && n2 != n4 && n3 != n4);
|
CHECK(n4 && n1 != n4 && n2 != n4 && n3 != n4);
|
||||||
CHECK(n4.set_value(STR("n4")));
|
CHECK(n4.set_value(STR("n4")));
|
||||||
@ -489,7 +489,7 @@ TEST_XML(dom_node_insert_child_after, "<node>foo<child/></node>")
|
|||||||
|
|
||||||
CHECK(node.insert_child_after(node_element, node) == xml_node());
|
CHECK(node.insert_child_after(node_element, node) == xml_node());
|
||||||
CHECK(child.insert_child_after(node_element, node) == xml_node());
|
CHECK(child.insert_child_after(node_element, node) == xml_node());
|
||||||
|
|
||||||
xml_node n1 = node.insert_child_after(node_element, child);
|
xml_node n1 = node.insert_child_after(node_element, child);
|
||||||
CHECK(n1 && n1 != node && n1 != child);
|
CHECK(n1 && n1 != node && n1 != child);
|
||||||
CHECK(n1.set_name(STR("n1")));
|
CHECK(n1.set_name(STR("n1")));
|
||||||
@ -523,7 +523,7 @@ TEST_XML(dom_node_insert_child_before, "<node>foo<child/></node>")
|
|||||||
|
|
||||||
CHECK(node.insert_child_before(node_element, node) == xml_node());
|
CHECK(node.insert_child_before(node_element, node) == xml_node());
|
||||||
CHECK(child.insert_child_before(node_element, node) == xml_node());
|
CHECK(child.insert_child_before(node_element, node) == xml_node());
|
||||||
|
|
||||||
xml_node n1 = node.insert_child_before(node_element, child);
|
xml_node n1 = node.insert_child_before(node_element, child);
|
||||||
CHECK(n1 && n1 != node && n1 != child);
|
CHECK(n1 && n1 != node && n1 != child);
|
||||||
CHECK(n1.set_name(STR("n1")));
|
CHECK(n1.set_name(STR("n1")));
|
||||||
@ -549,7 +549,7 @@ TEST_XML(dom_node_prepend_child_name, "<node>foo<child/></node>")
|
|||||||
{
|
{
|
||||||
CHECK(xml_node().prepend_child(STR("")) == xml_node());
|
CHECK(xml_node().prepend_child(STR("")) == xml_node());
|
||||||
CHECK(doc.child(STR("node")).first_child().prepend_child(STR("")) == xml_node());
|
CHECK(doc.child(STR("node")).first_child().prepend_child(STR("")) == xml_node());
|
||||||
|
|
||||||
xml_node n1 = doc.child(STR("node")).prepend_child(STR("n1"));
|
xml_node n1 = doc.child(STR("node")).prepend_child(STR("n1"));
|
||||||
CHECK(n1);
|
CHECK(n1);
|
||||||
|
|
||||||
@ -563,7 +563,7 @@ TEST_XML(dom_node_append_child_name, "<node>foo<child/></node>")
|
|||||||
{
|
{
|
||||||
CHECK(xml_node().append_child(STR("")) == xml_node());
|
CHECK(xml_node().append_child(STR("")) == xml_node());
|
||||||
CHECK(doc.child(STR("node")).first_child().append_child(STR("")) == xml_node());
|
CHECK(doc.child(STR("node")).first_child().append_child(STR("")) == xml_node());
|
||||||
|
|
||||||
xml_node n1 = doc.child(STR("node")).append_child(STR("n1"));
|
xml_node n1 = doc.child(STR("node")).append_child(STR("n1"));
|
||||||
CHECK(n1);
|
CHECK(n1);
|
||||||
|
|
||||||
@ -583,7 +583,7 @@ TEST_XML(dom_node_insert_child_after_name, "<node>foo<child/></node>")
|
|||||||
|
|
||||||
CHECK(node.insert_child_after(STR(""), node) == xml_node());
|
CHECK(node.insert_child_after(STR(""), node) == xml_node());
|
||||||
CHECK(child.insert_child_after(STR(""), node) == xml_node());
|
CHECK(child.insert_child_after(STR(""), node) == xml_node());
|
||||||
|
|
||||||
xml_node n1 = node.insert_child_after(STR("n1"), child);
|
xml_node n1 = node.insert_child_after(STR("n1"), child);
|
||||||
CHECK(n1 && n1 != node && n1 != child);
|
CHECK(n1 && n1 != node && n1 != child);
|
||||||
|
|
||||||
@ -605,7 +605,7 @@ TEST_XML(dom_node_insert_child_before_name, "<node>foo<child/></node>")
|
|||||||
|
|
||||||
CHECK(node.insert_child_before(STR(""), node) == xml_node());
|
CHECK(node.insert_child_before(STR(""), node) == xml_node());
|
||||||
CHECK(child.insert_child_before(STR(""), node) == xml_node());
|
CHECK(child.insert_child_before(STR(""), node) == xml_node());
|
||||||
|
|
||||||
xml_node n1 = node.insert_child_before(STR("n1"), child);
|
xml_node n1 = node.insert_child_before(STR("n1"), child);
|
||||||
CHECK(n1 && n1 != node && n1 != child);
|
CHECK(n1 && n1 != node && n1 != child);
|
||||||
|
|
||||||
@ -621,7 +621,7 @@ TEST_XML(dom_node_remove_child, "<node><n1/><n2/><n3/><child><n4/></child></node
|
|||||||
{
|
{
|
||||||
CHECK(!xml_node().remove_child(STR("a")));
|
CHECK(!xml_node().remove_child(STR("a")));
|
||||||
CHECK(!xml_node().remove_child(xml_node()));
|
CHECK(!xml_node().remove_child(xml_node()));
|
||||||
|
|
||||||
xml_node node = doc.child(STR("node"));
|
xml_node node = doc.child(STR("node"));
|
||||||
xml_node child = node.child(STR("child"));
|
xml_node child = node.child(STR("child"));
|
||||||
|
|
||||||
@ -665,7 +665,7 @@ TEST_XML(dom_node_prepend_copy, "<node>foo<child/></node>")
|
|||||||
CHECK(doc.child(STR("node")).first_child().prepend_copy(doc.child(STR("node"))) == xml_node());
|
CHECK(doc.child(STR("node")).first_child().prepend_copy(doc.child(STR("node"))) == xml_node());
|
||||||
CHECK(doc.prepend_copy(doc) == xml_node());
|
CHECK(doc.prepend_copy(doc) == xml_node());
|
||||||
CHECK(doc.prepend_copy(xml_node()) == xml_node());
|
CHECK(doc.prepend_copy(xml_node()) == xml_node());
|
||||||
|
|
||||||
xml_node n1 = doc.child(STR("node")).prepend_copy(doc.child(STR("node")).first_child());
|
xml_node n1 = doc.child(STR("node")).prepend_copy(doc.child(STR("node")).first_child());
|
||||||
CHECK(n1);
|
CHECK(n1);
|
||||||
CHECK_STRING(n1.value(), STR("foo"));
|
CHECK_STRING(n1.value(), STR("foo"));
|
||||||
@ -688,7 +688,7 @@ TEST_XML(dom_node_append_copy, "<node>foo<child/></node>")
|
|||||||
CHECK(doc.child(STR("node")).first_child().append_copy(doc.child(STR("node"))) == xml_node());
|
CHECK(doc.child(STR("node")).first_child().append_copy(doc.child(STR("node"))) == xml_node());
|
||||||
CHECK(doc.append_copy(doc) == xml_node());
|
CHECK(doc.append_copy(doc) == xml_node());
|
||||||
CHECK(doc.append_copy(xml_node()) == xml_node());
|
CHECK(doc.append_copy(xml_node()) == xml_node());
|
||||||
|
|
||||||
xml_node n1 = doc.child(STR("node")).append_copy(doc.child(STR("node")).first_child());
|
xml_node n1 = doc.child(STR("node")).append_copy(doc.child(STR("node")).first_child());
|
||||||
CHECK(n1);
|
CHECK(n1);
|
||||||
CHECK_STRING(n1.value(), STR("foo"));
|
CHECK_STRING(n1.value(), STR("foo"));
|
||||||
@ -712,7 +712,7 @@ TEST_XML(dom_node_insert_copy_after, "<node>foo<child/></node>")
|
|||||||
CHECK(doc.insert_copy_after(doc, doc) == xml_node());
|
CHECK(doc.insert_copy_after(doc, doc) == xml_node());
|
||||||
CHECK(doc.insert_copy_after(xml_node(), doc.child(STR("node"))) == xml_node());
|
CHECK(doc.insert_copy_after(xml_node(), doc.child(STR("node"))) == xml_node());
|
||||||
CHECK(doc.insert_copy_after(doc.child(STR("node")), xml_node()) == xml_node());
|
CHECK(doc.insert_copy_after(doc.child(STR("node")), xml_node()) == xml_node());
|
||||||
|
|
||||||
xml_node n1 = doc.child(STR("node")).insert_copy_after(doc.child(STR("node")).child(STR("child")), doc.child(STR("node")).first_child());
|
xml_node n1 = doc.child(STR("node")).insert_copy_after(doc.child(STR("node")).child(STR("child")), doc.child(STR("node")).first_child());
|
||||||
CHECK(n1);
|
CHECK(n1);
|
||||||
CHECK_STRING(n1.name(), STR("child"));
|
CHECK_STRING(n1.name(), STR("child"));
|
||||||
@ -736,7 +736,7 @@ TEST_XML(dom_node_insert_copy_before, "<node>foo<child/></node>")
|
|||||||
CHECK(doc.insert_copy_before(doc, doc) == xml_node());
|
CHECK(doc.insert_copy_before(doc, doc) == xml_node());
|
||||||
CHECK(doc.insert_copy_before(xml_node(), doc.child(STR("node"))) == xml_node());
|
CHECK(doc.insert_copy_before(xml_node(), doc.child(STR("node"))) == xml_node());
|
||||||
CHECK(doc.insert_copy_before(doc.child(STR("node")), xml_node()) == xml_node());
|
CHECK(doc.insert_copy_before(doc.child(STR("node")), xml_node()) == xml_node());
|
||||||
|
|
||||||
xml_node n1 = doc.child(STR("node")).insert_copy_before(doc.child(STR("node")).child(STR("child")), doc.child(STR("node")).first_child());
|
xml_node n1 = doc.child(STR("node")).insert_copy_before(doc.child(STR("node")).child(STR("child")), doc.child(STR("node")).first_child());
|
||||||
CHECK(n1);
|
CHECK(n1);
|
||||||
CHECK_STRING(n1.name(), STR("child"));
|
CHECK_STRING(n1.name(), STR("child"));
|
||||||
|
@ -303,7 +303,7 @@ TEST_XML(dom_text_set_value, "<node/>")
|
|||||||
TEST_XML(dom_text_assign_llong, "<node/>")
|
TEST_XML(dom_text_assign_llong, "<node/>")
|
||||||
{
|
{
|
||||||
xml_node node = doc.child(STR("node"));
|
xml_node node = doc.child(STR("node"));
|
||||||
|
|
||||||
node.append_child(STR("text1")).text() = -9223372036854775807ll;
|
node.append_child(STR("text1")).text() = -9223372036854775807ll;
|
||||||
node.append_child(STR("text2")).text() = -9223372036854775807ll - 1;
|
node.append_child(STR("text2")).text() = -9223372036854775807ll - 1;
|
||||||
xml_text() = -9223372036854775807ll - 1;
|
xml_text() = -9223372036854775807ll - 1;
|
||||||
@ -311,14 +311,14 @@ TEST_XML(dom_text_assign_llong, "<node/>")
|
|||||||
node.append_child(STR("text3")).text() = 18446744073709551615ull;
|
node.append_child(STR("text3")).text() = 18446744073709551615ull;
|
||||||
node.append_child(STR("text4")).text() = 18446744073709551614ull;
|
node.append_child(STR("text4")).text() = 18446744073709551614ull;
|
||||||
xml_text() = 18446744073709551615ull;
|
xml_text() = 18446744073709551615ull;
|
||||||
|
|
||||||
CHECK_NODE(node, STR("<node><text1>-9223372036854775807</text1><text2>-9223372036854775808</text2><text3>18446744073709551615</text3><text4>18446744073709551614</text4></node>"));
|
CHECK_NODE(node, STR("<node><text1>-9223372036854775807</text1><text2>-9223372036854775808</text2><text3>18446744073709551615</text3><text4>18446744073709551614</text4></node>"));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_XML(dom_text_set_value_llong, "<node/>")
|
TEST_XML(dom_text_set_value_llong, "<node/>")
|
||||||
{
|
{
|
||||||
xml_node node = doc.child(STR("node"));
|
xml_node node = doc.child(STR("node"));
|
||||||
|
|
||||||
CHECK(node.append_child(STR("text1")).text().set(-9223372036854775807ll));
|
CHECK(node.append_child(STR("text1")).text().set(-9223372036854775807ll));
|
||||||
CHECK(node.append_child(STR("text2")).text().set(-9223372036854775807ll - 1));
|
CHECK(node.append_child(STR("text2")).text().set(-9223372036854775807ll - 1));
|
||||||
CHECK(!xml_text().set(-9223372036854775807ll - 1));
|
CHECK(!xml_text().set(-9223372036854775807ll - 1));
|
||||||
|
@ -57,10 +57,10 @@ TEST_XML(dom_attr_next_previous_attribute, "<node attr1='1' attr2='2' />")
|
|||||||
|
|
||||||
CHECK(attr1.next_attribute() == attr2);
|
CHECK(attr1.next_attribute() == attr2);
|
||||||
CHECK(attr2.next_attribute() == xml_attribute());
|
CHECK(attr2.next_attribute() == xml_attribute());
|
||||||
|
|
||||||
CHECK(attr1.previous_attribute() == xml_attribute());
|
CHECK(attr1.previous_attribute() == xml_attribute());
|
||||||
CHECK(attr2.previous_attribute() == attr1);
|
CHECK(attr2.previous_attribute() == attr1);
|
||||||
|
|
||||||
CHECK(xml_attribute().next_attribute() == xml_attribute());
|
CHECK(xml_attribute().next_attribute() == xml_attribute());
|
||||||
CHECK(xml_attribute().previous_attribute() == xml_attribute());
|
CHECK(xml_attribute().previous_attribute() == xml_attribute());
|
||||||
}
|
}
|
||||||
@ -497,7 +497,7 @@ TEST_XML_FLAGS(dom_node_type, "<?xml?><!DOCTYPE><?pi?><!--comment--><node>pcdata
|
|||||||
CHECK((it++)->type() == node_element);
|
CHECK((it++)->type() == node_element);
|
||||||
|
|
||||||
xml_node_iterator cit = doc.child(STR("node")).begin();
|
xml_node_iterator cit = doc.child(STR("node")).begin();
|
||||||
|
|
||||||
CHECK((cit++)->type() == node_pcdata);
|
CHECK((cit++)->type() == node_pcdata);
|
||||||
CHECK((cit++)->type() == node_cdata);
|
CHECK((cit++)->type() == node_cdata);
|
||||||
}
|
}
|
||||||
@ -516,7 +516,7 @@ TEST_XML_FLAGS(dom_node_name_value, "<?xml?><!DOCTYPE id><?pi?><!--comment--><no
|
|||||||
CHECK_NAME_VALUE(*it++, STR("node"), STR(""));
|
CHECK_NAME_VALUE(*it++, STR("node"), STR(""));
|
||||||
|
|
||||||
xml_node_iterator cit = doc.child(STR("node")).begin();
|
xml_node_iterator cit = doc.child(STR("node")).begin();
|
||||||
|
|
||||||
CHECK_NAME_VALUE(*cit++, STR(""), STR("pcdata"));
|
CHECK_NAME_VALUE(*cit++, STR(""), STR("pcdata"));
|
||||||
CHECK_NAME_VALUE(*cit++, STR(""), STR("cdata"));
|
CHECK_NAME_VALUE(*cit++, STR(""), STR("cdata"));
|
||||||
}
|
}
|
||||||
@ -555,10 +555,10 @@ TEST_XML(dom_node_next_previous_sibling, "<node><child1/><child2/><child3/></nod
|
|||||||
|
|
||||||
CHECK(child1.next_sibling() == child2);
|
CHECK(child1.next_sibling() == child2);
|
||||||
CHECK(child3.next_sibling() == xml_node());
|
CHECK(child3.next_sibling() == xml_node());
|
||||||
|
|
||||||
CHECK(child1.previous_sibling() == xml_node());
|
CHECK(child1.previous_sibling() == xml_node());
|
||||||
CHECK(child3.previous_sibling() == child2);
|
CHECK(child3.previous_sibling() == child2);
|
||||||
|
|
||||||
CHECK(child1.next_sibling(STR("child3")) == child3);
|
CHECK(child1.next_sibling(STR("child3")) == child3);
|
||||||
CHECK(child1.next_sibling(STR("child")) == xml_node());
|
CHECK(child1.next_sibling(STR("child")) == xml_node());
|
||||||
|
|
||||||
@ -728,13 +728,13 @@ TEST_XML(dom_node_find_node, "<node><child1/><child2/></node>")
|
|||||||
TEST_XML(dom_node_path, "<node><child1>text<child2/></child1></node>")
|
TEST_XML(dom_node_path, "<node><child1>text<child2/></child1></node>")
|
||||||
{
|
{
|
||||||
CHECK(xml_node().path() == STR(""));
|
CHECK(xml_node().path() == STR(""));
|
||||||
|
|
||||||
CHECK(doc.path() == STR(""));
|
CHECK(doc.path() == STR(""));
|
||||||
CHECK(doc.child(STR("node")).path() == STR("/node"));
|
CHECK(doc.child(STR("node")).path() == STR("/node"));
|
||||||
CHECK(doc.child(STR("node")).child(STR("child1")).path() == STR("/node/child1"));
|
CHECK(doc.child(STR("node")).child(STR("child1")).path() == STR("/node/child1"));
|
||||||
CHECK(doc.child(STR("node")).child(STR("child1")).child(STR("child2")).path() == STR("/node/child1/child2"));
|
CHECK(doc.child(STR("node")).child(STR("child1")).child(STR("child2")).path() == STR("/node/child1/child2"));
|
||||||
CHECK(doc.child(STR("node")).child(STR("child1")).first_child().path() == STR("/node/child1/"));
|
CHECK(doc.child(STR("node")).child(STR("child1")).first_child().path() == STR("/node/child1/"));
|
||||||
|
|
||||||
CHECK(doc.child(STR("node")).child(STR("child1")).path('\\') == STR("\\node\\child1"));
|
CHECK(doc.child(STR("node")).child(STR("child1")).path('\\') == STR("\\node\\child1"));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -743,7 +743,7 @@ TEST_XML(dom_node_first_element_by_path, "<node><child1>text<child2/></child1></
|
|||||||
{
|
{
|
||||||
CHECK(xml_node().first_element_by_path(STR("/")) == xml_node());
|
CHECK(xml_node().first_element_by_path(STR("/")) == xml_node());
|
||||||
CHECK(xml_node().first_element_by_path(STR("a")) == xml_node());
|
CHECK(xml_node().first_element_by_path(STR("a")) == xml_node());
|
||||||
|
|
||||||
CHECK(doc.first_element_by_path(STR("")) == doc);
|
CHECK(doc.first_element_by_path(STR("")) == doc);
|
||||||
CHECK(doc.first_element_by_path(STR("/")) == doc);
|
CHECK(doc.first_element_by_path(STR("/")) == doc);
|
||||||
|
|
||||||
@ -757,7 +757,7 @@ TEST_XML(dom_node_first_element_by_path, "<node><child1>text<child2/></child1></
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
CHECK(doc.first_element_by_path(STR("/node/child2")) == xml_node());
|
CHECK(doc.first_element_by_path(STR("/node/child2")) == xml_node());
|
||||||
|
|
||||||
CHECK(doc.first_element_by_path(STR("\\node\\child1"), '\\') == doc.child(STR("node")).child(STR("child1")));
|
CHECK(doc.first_element_by_path(STR("\\node\\child1"), '\\') == doc.child(STR("node")).child(STR("child1")));
|
||||||
|
|
||||||
CHECK(doc.child(STR("node")).first_element_by_path(STR("..")) == doc);
|
CHECK(doc.child(STR("node")).first_element_by_path(STR("..")) == doc);
|
||||||
@ -919,7 +919,7 @@ TEST_XML_FLAGS(dom_offset_debug, "<?xml?><!DOCTYPE><?pi?><!--comment--><node>pcd
|
|||||||
CHECK((it++)->offset_debug() == 38);
|
CHECK((it++)->offset_debug() == 38);
|
||||||
|
|
||||||
xml_node_iterator cit = doc.child(STR("node")).begin();
|
xml_node_iterator cit = doc.child(STR("node")).begin();
|
||||||
|
|
||||||
CHECK((cit++)->offset_debug() == 43);
|
CHECK((cit++)->offset_debug() == 43);
|
||||||
CHECK((cit++)->offset_debug() == 58);
|
CHECK((cit++)->offset_debug() == 58);
|
||||||
}
|
}
|
||||||
@ -966,7 +966,7 @@ TEST_XML(dom_internal_object, "<node attr='value'>value</node>")
|
|||||||
xml_node node = doc.child(STR("node"));
|
xml_node node = doc.child(STR("node"));
|
||||||
xml_attribute attr = node.first_attribute();
|
xml_attribute attr = node.first_attribute();
|
||||||
xml_node value = node.first_child();
|
xml_node value = node.first_child();
|
||||||
|
|
||||||
CHECK(xml_node().internal_object() == 0);
|
CHECK(xml_node().internal_object() == 0);
|
||||||
CHECK(xml_attribute().internal_object() == 0);
|
CHECK(xml_attribute().internal_object() == 0);
|
||||||
|
|
||||||
@ -988,7 +988,7 @@ TEST_XML(dom_hash_value, "<node attr='value'>value</node>")
|
|||||||
xml_node node = doc.child(STR("node"));
|
xml_node node = doc.child(STR("node"));
|
||||||
xml_attribute attr = node.first_attribute();
|
xml_attribute attr = node.first_attribute();
|
||||||
xml_node value = node.first_child();
|
xml_node value = node.first_child();
|
||||||
|
|
||||||
CHECK(xml_node().hash_value() == 0);
|
CHECK(xml_node().hash_value() == 0);
|
||||||
CHECK(xml_attribute().hash_value() == 0);
|
CHECK(xml_attribute().hash_value() == 0);
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ TEST(memory_custom_memory_management)
|
|||||||
CHECK(page_allocs == 0 && page_deallocs == 0);
|
CHECK(page_allocs == 0 && page_deallocs == 0);
|
||||||
|
|
||||||
CHECK(doc.load_string(STR("<node />")));
|
CHECK(doc.load_string(STR("<node />")));
|
||||||
|
|
||||||
CHECK(page_allocs == 1 && page_deallocs == 0);
|
CHECK(page_allocs == 1 && page_deallocs == 0);
|
||||||
|
|
||||||
// modify document (no new page)
|
// modify document (no new page)
|
||||||
|
@ -82,7 +82,7 @@ TEST(parse_pi_error)
|
|||||||
CHECK(doc.load_string(STR("<?name&"), flags).status == status_bad_pi);
|
CHECK(doc.load_string(STR("<?name&"), flags).status == status_bad_pi);
|
||||||
CHECK(doc.load_string(STR("<?name&?"), flags).status == status_bad_pi);
|
CHECK(doc.load_string(STR("<?name&?"), flags).status == status_bad_pi);
|
||||||
}
|
}
|
||||||
|
|
||||||
CHECK(doc.load_string(STR("<?xx#?>"), parse_fragment | parse_pi).status == status_bad_pi);
|
CHECK(doc.load_string(STR("<?xx#?>"), parse_fragment | parse_pi).status == status_bad_pi);
|
||||||
CHECK(doc.load_string(STR("<?name&?>"), parse_fragment | parse_pi).status == status_bad_pi);
|
CHECK(doc.load_string(STR("<?name&?>"), parse_fragment | parse_pi).status == status_bad_pi);
|
||||||
CHECK(doc.load_string(STR("<?name& x?>"), parse_fragment | parse_pi).status == status_bad_pi);
|
CHECK(doc.load_string(STR("<?name& x?>"), parse_fragment | parse_pi).status == status_bad_pi);
|
||||||
@ -235,9 +235,9 @@ TEST(parse_ws_pcdata_skip)
|
|||||||
CHECK(!doc.first_child());
|
CHECK(!doc.first_child());
|
||||||
|
|
||||||
CHECK(doc.load_string(STR("<root> <node> </node> </root>"), parse_minimal));
|
CHECK(doc.load_string(STR("<root> <node> </node> </root>"), parse_minimal));
|
||||||
|
|
||||||
xml_node root = doc.child(STR("root"));
|
xml_node root = doc.child(STR("root"));
|
||||||
|
|
||||||
CHECK(root.first_child() == root.last_child());
|
CHECK(root.first_child() == root.last_child());
|
||||||
CHECK(!root.first_child().first_child());
|
CHECK(!root.first_child().first_child());
|
||||||
}
|
}
|
||||||
@ -855,7 +855,7 @@ TEST(parse_declaration_error)
|
|||||||
CHECK(doc.load_string(STR("<?xml>"), flags).status == status_bad_pi);
|
CHECK(doc.load_string(STR("<?xml>"), flags).status == status_bad_pi);
|
||||||
CHECK(doc.load_string(STR("<?xml version='1>"), flags).status == status_bad_pi);
|
CHECK(doc.load_string(STR("<?xml version='1>"), flags).status == status_bad_pi);
|
||||||
}
|
}
|
||||||
|
|
||||||
CHECK(doc.load_string(STR("<?xml version='1?>"), parse_fragment | parse_declaration).status == status_bad_attribute);
|
CHECK(doc.load_string(STR("<?xml version='1?>"), parse_fragment | parse_declaration).status == status_bad_attribute);
|
||||||
CHECK(doc.load_string(STR("<foo><?xml version='1'?></foo>"), parse_fragment | parse_declaration).status == status_bad_pi);
|
CHECK(doc.load_string(STR("<foo><?xml version='1'?></foo>"), parse_fragment | parse_declaration).status == status_bad_pi);
|
||||||
}
|
}
|
||||||
|
@ -196,7 +196,7 @@ TEST(xpath_long_numbers_parse)
|
|||||||
{
|
{
|
||||||
const pugi::char_t* str_flt_max = STR("340282346638528860000000000000000000000");
|
const pugi::char_t* str_flt_max = STR("340282346638528860000000000000000000000");
|
||||||
const pugi::char_t* str_flt_max_dec = STR("340282346638528860000000000000000000000.000000");
|
const pugi::char_t* str_flt_max_dec = STR("340282346638528860000000000000000000000.000000");
|
||||||
|
|
||||||
const pugi::char_t* str_dbl_max = STR("179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000");
|
const pugi::char_t* str_dbl_max = STR("179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000");
|
||||||
const pugi::char_t* str_dbl_max_dec = STR("179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.000000");
|
const pugi::char_t* str_dbl_max_dec = STR("179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.000000");
|
||||||
|
|
||||||
@ -225,7 +225,7 @@ TEST(xpath_long_numbers_stringize)
|
|||||||
{
|
{
|
||||||
const pugi::char_t* str_flt_max = STR("340282346638528860000000000000000000000");
|
const pugi::char_t* str_flt_max = STR("340282346638528860000000000000000000000");
|
||||||
const pugi::char_t* str_flt_max_dec = STR("340282346638528860000000000000000000000.000000");
|
const pugi::char_t* str_flt_max_dec = STR("340282346638528860000000000000000000000.000000");
|
||||||
|
|
||||||
const pugi::char_t* str_dbl_max = STR("179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000");
|
const pugi::char_t* str_dbl_max = STR("179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000");
|
||||||
const pugi::char_t* str_dbl_max_dec = STR("179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.000000");
|
const pugi::char_t* str_dbl_max_dec = STR("179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.000000");
|
||||||
|
|
||||||
|
@ -31,12 +31,12 @@ TEST_XML(xpath_api_select_node, "<node><head/><foo id='1'/><foo/><tail/></node>"
|
|||||||
CHECK(n2.node().attribute(STR("id")).as_int() == 1);
|
CHECK(n2.node().attribute(STR("id")).as_int() == 1);
|
||||||
|
|
||||||
xpath_node n3 = doc.select_node(STR("node/bar"));
|
xpath_node n3 = doc.select_node(STR("node/bar"));
|
||||||
|
|
||||||
CHECK(!n3);
|
CHECK(!n3);
|
||||||
|
|
||||||
xpath_node n4 = doc.select_node(STR("node/head/following-sibling::foo"));
|
xpath_node n4 = doc.select_node(STR("node/head/following-sibling::foo"));
|
||||||
xpath_node n5 = doc.select_node(STR("node/tail/preceding-sibling::foo"));
|
xpath_node n5 = doc.select_node(STR("node/tail/preceding-sibling::foo"));
|
||||||
|
|
||||||
CHECK(n4.node().attribute(STR("id")).as_int() == 1);
|
CHECK(n4.node().attribute(STR("id")).as_int() == 1);
|
||||||
CHECK(n5.node().attribute(STR("id")).as_int() == 1);
|
CHECK(n5.node().attribute(STR("id")).as_int() == 1);
|
||||||
}
|
}
|
||||||
@ -258,7 +258,7 @@ TEST(xpath_api_evaluate_string)
|
|||||||
// test for just enough space
|
// test for just enough space
|
||||||
std::basic_string<char_t> s1 = base;
|
std::basic_string<char_t> s1 = base;
|
||||||
CHECK(q.evaluate_string(&s1[0], 11, xml_node()) == 11 && memcmp(&s1[0], STR("0123456789\0xxxxx"), 16 * sizeof(char_t)) == 0);
|
CHECK(q.evaluate_string(&s1[0], 11, xml_node()) == 11 && memcmp(&s1[0], STR("0123456789\0xxxxx"), 16 * sizeof(char_t)) == 0);
|
||||||
|
|
||||||
// test for just not enough space
|
// test for just not enough space
|
||||||
std::basic_string<char_t> s2 = base;
|
std::basic_string<char_t> s2 = base;
|
||||||
CHECK(q.evaluate_string(&s2[0], 10, xml_node()) == 11 && memcmp(&s2[0], STR("012345678\0xxxxxx"), 16 * sizeof(char_t)) == 0);
|
CHECK(q.evaluate_string(&s2[0], 10, xml_node()) == 11 && memcmp(&s2[0], STR("012345678\0xxxxxx"), 16 * sizeof(char_t)) == 0);
|
||||||
@ -292,7 +292,7 @@ TEST(xpath_api_return_type)
|
|||||||
TEST(xpath_api_query_bool)
|
TEST(xpath_api_query_bool)
|
||||||
{
|
{
|
||||||
xpath_query q(STR("node"));
|
xpath_query q(STR("node"));
|
||||||
|
|
||||||
CHECK(q);
|
CHECK(q);
|
||||||
CHECK((!q) == false);
|
CHECK((!q) == false);
|
||||||
}
|
}
|
||||||
@ -301,7 +301,7 @@ TEST(xpath_api_query_bool)
|
|||||||
TEST(xpath_api_query_bool_fail)
|
TEST(xpath_api_query_bool_fail)
|
||||||
{
|
{
|
||||||
xpath_query q(STR(""));
|
xpath_query q(STR(""));
|
||||||
|
|
||||||
CHECK((q ? true : false) == false);
|
CHECK((q ? true : false) == false);
|
||||||
CHECK((!q) == true);
|
CHECK((!q) == true);
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ TEST_XML(xpath_number_number, "<node>123</node>")
|
|||||||
{
|
{
|
||||||
xml_node c;
|
xml_node c;
|
||||||
xml_node n = doc.child(STR("node")).first_child();
|
xml_node n = doc.child(STR("node")).first_child();
|
||||||
|
|
||||||
// number with 0 arguments
|
// number with 0 arguments
|
||||||
CHECK_XPATH_NUMBER_NAN(c, STR("number()"));
|
CHECK_XPATH_NUMBER_NAN(c, STR("number()"));
|
||||||
CHECK_XPATH_NUMBER(n, STR("number()"), 123);
|
CHECK_XPATH_NUMBER(n, STR("number()"), 123);
|
||||||
@ -35,7 +35,7 @@ TEST_XML(xpath_number_number, "<node>123</node>")
|
|||||||
|
|
||||||
// number with 1 number argument
|
// number with 1 number argument
|
||||||
CHECK_XPATH_NUMBER(c, STR("number(1)"), 1);
|
CHECK_XPATH_NUMBER(c, STR("number(1)"), 1);
|
||||||
|
|
||||||
// number with 2 arguments
|
// number with 2 arguments
|
||||||
CHECK_XPATH_FAIL(STR("number(1, 2)"));
|
CHECK_XPATH_FAIL(STR("number(1, 2)"));
|
||||||
}
|
}
|
||||||
@ -44,21 +44,21 @@ TEST_XML(xpath_number_sum, "<node>123<child>789</child></node><node/>")
|
|||||||
{
|
{
|
||||||
xml_node c;
|
xml_node c;
|
||||||
xml_node n = doc.child(STR("node"));
|
xml_node n = doc.child(STR("node"));
|
||||||
|
|
||||||
// sum with 0 arguments
|
// sum with 0 arguments
|
||||||
CHECK_XPATH_FAIL(STR("sum()"));
|
CHECK_XPATH_FAIL(STR("sum()"));
|
||||||
|
|
||||||
// sum with 1 argument
|
// sum with 1 argument
|
||||||
CHECK_XPATH_NUMBER(c, STR("sum(.)"), 0);
|
CHECK_XPATH_NUMBER(c, STR("sum(.)"), 0);
|
||||||
CHECK_XPATH_NUMBER(n, STR("sum(.)"), 123789); // 123 .. 789
|
CHECK_XPATH_NUMBER(n, STR("sum(.)"), 123789); // 123 .. 789
|
||||||
|
|
||||||
CHECK_XPATH_NUMBER(n, STR("sum(./descendant-or-self::node())"), 125490); // node + 123 + child + 789 = 123789 + 123 + 789 + 789 = 125490
|
CHECK_XPATH_NUMBER(n, STR("sum(./descendant-or-self::node())"), 125490); // node + 123 + child + 789 = 123789 + 123 + 789 + 789 = 125490
|
||||||
CHECK_XPATH_NUMBER(n, STR("sum(.//node())"), 1701); // 123 + child + 789 = 123 + 789 + 789
|
CHECK_XPATH_NUMBER(n, STR("sum(.//node())"), 1701); // 123 + child + 789 = 123 + 789 + 789
|
||||||
CHECK_XPATH_NUMBER_NAN(doc.last_child(), STR("sum(.)"));
|
CHECK_XPATH_NUMBER_NAN(doc.last_child(), STR("sum(.)"));
|
||||||
|
|
||||||
// sum with 2 arguments
|
// sum with 2 arguments
|
||||||
CHECK_XPATH_FAIL(STR("sum(1, 2)"));
|
CHECK_XPATH_FAIL(STR("sum(1, 2)"));
|
||||||
|
|
||||||
// sum with 1 non-node-set argument
|
// sum with 1 non-node-set argument
|
||||||
CHECK_XPATH_FAIL(STR("sum(1)"));
|
CHECK_XPATH_FAIL(STR("sum(1)"));
|
||||||
}
|
}
|
||||||
@ -155,7 +155,7 @@ TEST(xpath_number_round)
|
|||||||
TEST_XML(xpath_boolean_boolean, "<node />")
|
TEST_XML(xpath_boolean_boolean, "<node />")
|
||||||
{
|
{
|
||||||
xml_node c;
|
xml_node c;
|
||||||
|
|
||||||
// boolean with 0 arguments
|
// boolean with 0 arguments
|
||||||
CHECK_XPATH_FAIL(STR("boolean()"));
|
CHECK_XPATH_FAIL(STR("boolean()"));
|
||||||
|
|
||||||
@ -182,14 +182,14 @@ TEST_XML(xpath_boolean_boolean, "<node />")
|
|||||||
TEST(xpath_boolean_not)
|
TEST(xpath_boolean_not)
|
||||||
{
|
{
|
||||||
xml_node c;
|
xml_node c;
|
||||||
|
|
||||||
// not with 0 arguments
|
// not with 0 arguments
|
||||||
CHECK_XPATH_FAIL(STR("not()"));
|
CHECK_XPATH_FAIL(STR("not()"));
|
||||||
|
|
||||||
// not with 1 argument
|
// not with 1 argument
|
||||||
CHECK_XPATH_BOOLEAN(c, STR("not(true())"), false);
|
CHECK_XPATH_BOOLEAN(c, STR("not(true())"), false);
|
||||||
CHECK_XPATH_BOOLEAN(c, STR("not(false())"), true);
|
CHECK_XPATH_BOOLEAN(c, STR("not(false())"), true);
|
||||||
|
|
||||||
// boolean with 2 arguments
|
// boolean with 2 arguments
|
||||||
CHECK_XPATH_FAIL(STR("not(1, 2)"));
|
CHECK_XPATH_FAIL(STR("not(1, 2)"));
|
||||||
}
|
}
|
||||||
@ -197,7 +197,7 @@ TEST(xpath_boolean_not)
|
|||||||
TEST(xpath_boolean_true)
|
TEST(xpath_boolean_true)
|
||||||
{
|
{
|
||||||
xml_node c;
|
xml_node c;
|
||||||
|
|
||||||
// true with 0 arguments
|
// true with 0 arguments
|
||||||
CHECK_XPATH_BOOLEAN(c, STR("true()"), true);
|
CHECK_XPATH_BOOLEAN(c, STR("true()"), true);
|
||||||
|
|
||||||
@ -208,7 +208,7 @@ TEST(xpath_boolean_true)
|
|||||||
TEST(xpath_boolean_false)
|
TEST(xpath_boolean_false)
|
||||||
{
|
{
|
||||||
xml_node c;
|
xml_node c;
|
||||||
|
|
||||||
// false with 0 arguments
|
// false with 0 arguments
|
||||||
CHECK_XPATH_BOOLEAN(c, STR("false()"), false);
|
CHECK_XPATH_BOOLEAN(c, STR("false()"), false);
|
||||||
|
|
||||||
@ -219,7 +219,7 @@ TEST(xpath_boolean_false)
|
|||||||
TEST_XML(xpath_boolean_lang, "<node xml:lang='en'><child xml:lang='zh-UK'><subchild attr=''/></child></node><foo><bar/></foo>")
|
TEST_XML(xpath_boolean_lang, "<node xml:lang='en'><child xml:lang='zh-UK'><subchild attr=''/></child></node><foo><bar/></foo>")
|
||||||
{
|
{
|
||||||
xml_node c;
|
xml_node c;
|
||||||
|
|
||||||
// lang with 0 arguments
|
// lang with 0 arguments
|
||||||
CHECK_XPATH_FAIL(STR("lang()"));
|
CHECK_XPATH_FAIL(STR("lang()"));
|
||||||
|
|
||||||
@ -228,7 +228,7 @@ TEST_XML(xpath_boolean_lang, "<node xml:lang='en'><child xml:lang='zh-UK'><subch
|
|||||||
CHECK_XPATH_BOOLEAN(doc.child(STR("foo")), STR("lang('en')"), false);
|
CHECK_XPATH_BOOLEAN(doc.child(STR("foo")), STR("lang('en')"), false);
|
||||||
CHECK_XPATH_BOOLEAN(doc.child(STR("foo")), STR("lang('')"), false);
|
CHECK_XPATH_BOOLEAN(doc.child(STR("foo")), STR("lang('')"), false);
|
||||||
CHECK_XPATH_BOOLEAN(doc.child(STR("foo")).child(STR("bar")), STR("lang('en')"), false);
|
CHECK_XPATH_BOOLEAN(doc.child(STR("foo")).child(STR("bar")), STR("lang('en')"), false);
|
||||||
|
|
||||||
// lang with 1 argument, same language/prefix
|
// lang with 1 argument, same language/prefix
|
||||||
CHECK_XPATH_BOOLEAN(doc.child(STR("node")), STR("lang('en')"), true);
|
CHECK_XPATH_BOOLEAN(doc.child(STR("node")), STR("lang('en')"), true);
|
||||||
CHECK_XPATH_BOOLEAN(doc.child(STR("node")).child(STR("child")), STR("lang('zh-uk')"), true);
|
CHECK_XPATH_BOOLEAN(doc.child(STR("node")).child(STR("child")), STR("lang('zh-uk')"), true);
|
||||||
@ -373,7 +373,7 @@ TEST(xpath_string_substring_before)
|
|||||||
|
|
||||||
// substring-before with 1 argument
|
// substring-before with 1 argument
|
||||||
CHECK_XPATH_FAIL(STR("substring-before('a')"));
|
CHECK_XPATH_FAIL(STR("substring-before('a')"));
|
||||||
|
|
||||||
// substring-before with 2 arguments
|
// substring-before with 2 arguments
|
||||||
CHECK_XPATH_STRING(c, STR("substring-before('abc', 'abc')"), STR(""));
|
CHECK_XPATH_STRING(c, STR("substring-before('abc', 'abc')"), STR(""));
|
||||||
CHECK_XPATH_STRING(c, STR("substring-before('abc', 'a')"), STR(""));
|
CHECK_XPATH_STRING(c, STR("substring-before('abc', 'a')"), STR(""));
|
||||||
@ -382,7 +382,7 @@ TEST(xpath_string_substring_before)
|
|||||||
CHECK_XPATH_STRING(c, STR("substring-before('abc', 'c')"), STR("ab"));
|
CHECK_XPATH_STRING(c, STR("substring-before('abc', 'c')"), STR("ab"));
|
||||||
CHECK_XPATH_STRING(c, STR("substring-before('abc', '')"), STR(""));
|
CHECK_XPATH_STRING(c, STR("substring-before('abc', '')"), STR(""));
|
||||||
CHECK_XPATH_STRING(c, STR("substring-before('', '')"), STR(""));
|
CHECK_XPATH_STRING(c, STR("substring-before('', '')"), STR(""));
|
||||||
|
|
||||||
// substring-before with 2 arguments, from W3C standard
|
// substring-before with 2 arguments, from W3C standard
|
||||||
CHECK_XPATH_STRING(c, STR("substring-before(\"1999/04/01\",\"/\")"), STR("1999"));
|
CHECK_XPATH_STRING(c, STR("substring-before(\"1999/04/01\",\"/\")"), STR("1999"));
|
||||||
|
|
||||||
@ -399,7 +399,7 @@ TEST(xpath_string_substring_after)
|
|||||||
|
|
||||||
// substring-after with 1 argument
|
// substring-after with 1 argument
|
||||||
CHECK_XPATH_FAIL(STR("substring-after('a')"));
|
CHECK_XPATH_FAIL(STR("substring-after('a')"));
|
||||||
|
|
||||||
// substring-after with 2 arguments
|
// substring-after with 2 arguments
|
||||||
CHECK_XPATH_STRING(c, STR("substring-after('abc', 'abc')"), STR(""));
|
CHECK_XPATH_STRING(c, STR("substring-after('abc', 'abc')"), STR(""));
|
||||||
CHECK_XPATH_STRING(c, STR("substring-after('abc', 'a')"), STR("bc"));
|
CHECK_XPATH_STRING(c, STR("substring-after('abc', 'a')"), STR("bc"));
|
||||||
@ -430,10 +430,10 @@ TEST(xpath_string_substring)
|
|||||||
|
|
||||||
// substring with 0 arguments
|
// substring with 0 arguments
|
||||||
CHECK_XPATH_FAIL(STR("substring()"));
|
CHECK_XPATH_FAIL(STR("substring()"));
|
||||||
|
|
||||||
// substring with 1 argument
|
// substring with 1 argument
|
||||||
CHECK_XPATH_FAIL(STR("substring('')"));
|
CHECK_XPATH_FAIL(STR("substring('')"));
|
||||||
|
|
||||||
// substring with 2 arguments
|
// substring with 2 arguments
|
||||||
CHECK_XPATH_STRING(c, STR("substring('abcd', 2)"), STR("bcd"));
|
CHECK_XPATH_STRING(c, STR("substring('abcd', 2)"), STR("bcd"));
|
||||||
CHECK_XPATH_STRING(c, STR("substring('abcd', 1)"), STR("abcd"));
|
CHECK_XPATH_STRING(c, STR("substring('abcd', 1)"), STR("abcd"));
|
||||||
@ -517,7 +517,7 @@ TEST_XML_FLAGS(xpath_string_normalize_space, "<node> \t\r\rval1 \rval2\r\nval3\
|
|||||||
// normalize-space with 0 arguments
|
// normalize-space with 0 arguments
|
||||||
CHECK_XPATH_STRING(c, STR("normalize-space()"), STR(""));
|
CHECK_XPATH_STRING(c, STR("normalize-space()"), STR(""));
|
||||||
CHECK_XPATH_STRING(n, STR("normalize-space()"), STR("val1 val2 val3 val4"));
|
CHECK_XPATH_STRING(n, STR("normalize-space()"), STR("val1 val2 val3 val4"));
|
||||||
|
|
||||||
// normalize-space with 1 argument
|
// normalize-space with 1 argument
|
||||||
CHECK_XPATH_STRING(c, STR("normalize-space('')"), STR(""));
|
CHECK_XPATH_STRING(c, STR("normalize-space('')"), STR(""));
|
||||||
CHECK_XPATH_STRING(c, STR("normalize-space('abcd')"), STR("abcd"));
|
CHECK_XPATH_STRING(c, STR("normalize-space('abcd')"), STR("abcd"));
|
||||||
@ -526,7 +526,7 @@ TEST_XML_FLAGS(xpath_string_normalize_space, "<node> \t\r\rval1 \rval2\r\nval3\
|
|||||||
CHECK_XPATH_STRING(c, STR("normalize-space('ab\r\n\tcd')"), STR("ab cd"));
|
CHECK_XPATH_STRING(c, STR("normalize-space('ab\r\n\tcd')"), STR("ab cd"));
|
||||||
CHECK_XPATH_STRING(c, STR("normalize-space('ab cd')"), STR("ab cd"));
|
CHECK_XPATH_STRING(c, STR("normalize-space('ab cd')"), STR("ab cd"));
|
||||||
CHECK_XPATH_STRING(c, STR("normalize-space('\07')"), STR("\07"));
|
CHECK_XPATH_STRING(c, STR("normalize-space('\07')"), STR("\07"));
|
||||||
|
|
||||||
// normalize-space with 2 arguments
|
// normalize-space with 2 arguments
|
||||||
CHECK_XPATH_FAIL(STR("normalize-space(1, 2)"));
|
CHECK_XPATH_FAIL(STR("normalize-space(1, 2)"));
|
||||||
}
|
}
|
||||||
@ -537,13 +537,13 @@ TEST(xpath_string_translate)
|
|||||||
|
|
||||||
// translate with 0 arguments
|
// translate with 0 arguments
|
||||||
CHECK_XPATH_FAIL(STR("translate()"));
|
CHECK_XPATH_FAIL(STR("translate()"));
|
||||||
|
|
||||||
// translate with 1 argument
|
// translate with 1 argument
|
||||||
CHECK_XPATH_FAIL(STR("translate('a')"));
|
CHECK_XPATH_FAIL(STR("translate('a')"));
|
||||||
|
|
||||||
// translate with 2 arguments
|
// translate with 2 arguments
|
||||||
CHECK_XPATH_FAIL(STR("translate('a', 'b')"));
|
CHECK_XPATH_FAIL(STR("translate('a', 'b')"));
|
||||||
|
|
||||||
// translate with 3 arguments
|
// translate with 3 arguments
|
||||||
CHECK_XPATH_STRING(c, STR("translate('abc', '', '')"), STR("abc"));
|
CHECK_XPATH_STRING(c, STR("translate('abc', '', '')"), STR("abc"));
|
||||||
CHECK_XPATH_STRING(c, STR("translate('abc', '', 'foo')"), STR("abc"));
|
CHECK_XPATH_STRING(c, STR("translate('abc', '', 'foo')"), STR("abc"));
|
||||||
@ -604,7 +604,7 @@ TEST_XML(xpath_nodeset_position, "<node><c1/><c1/><c2/><c3/><c3/><c3/><c3/></nod
|
|||||||
CHECK_XPATH_NODESET(n, STR("c1[position() = 3]"));
|
CHECK_XPATH_NODESET(n, STR("c1[position() = 3]"));
|
||||||
CHECK_XPATH_NODESET(n, STR("c2/preceding-sibling::node()[position() = 1]")) % 4;
|
CHECK_XPATH_NODESET(n, STR("c2/preceding-sibling::node()[position() = 1]")) % 4;
|
||||||
CHECK_XPATH_NODESET(n, STR("c2/preceding-sibling::node()[position() = 2]")) % 3;
|
CHECK_XPATH_NODESET(n, STR("c2/preceding-sibling::node()[position() = 2]")) % 3;
|
||||||
|
|
||||||
// position with 1 argument
|
// position with 1 argument
|
||||||
CHECK_XPATH_FAIL(STR("position(c)"));
|
CHECK_XPATH_FAIL(STR("position(c)"));
|
||||||
}
|
}
|
||||||
@ -640,7 +640,7 @@ TEST_XML(xpath_nodeset_id, "<node id='foo'/>")
|
|||||||
|
|
||||||
// id with 0 arguments
|
// id with 0 arguments
|
||||||
CHECK_XPATH_FAIL(STR("id()"));
|
CHECK_XPATH_FAIL(STR("id()"));
|
||||||
|
|
||||||
// id with 1 argument - no DTD => no id
|
// id with 1 argument - no DTD => no id
|
||||||
CHECK_XPATH_NODESET(n, STR("id('foo')"));
|
CHECK_XPATH_NODESET(n, STR("id('foo')"));
|
||||||
|
|
||||||
@ -656,7 +656,7 @@ TEST_XML_FLAGS(xpath_nodeset_local_name, "<node xmlns:foo='http://foo'><c1>text<
|
|||||||
// local-name with 0 arguments
|
// local-name with 0 arguments
|
||||||
CHECK_XPATH_STRING(c, STR("local-name()"), STR(""));
|
CHECK_XPATH_STRING(c, STR("local-name()"), STR(""));
|
||||||
CHECK_XPATH_STRING(n, STR("local-name()"), STR("node"));
|
CHECK_XPATH_STRING(n, STR("local-name()"), STR("node"));
|
||||||
|
|
||||||
// local-name with 1 non-node-set argument
|
// local-name with 1 non-node-set argument
|
||||||
CHECK_XPATH_FAIL(STR("local-name(1)"));
|
CHECK_XPATH_FAIL(STR("local-name(1)"));
|
||||||
|
|
||||||
@ -681,7 +681,7 @@ TEST_XML_FLAGS(xpath_nodeset_namespace_uri, "<node xmlns:foo='http://foo'><c1>te
|
|||||||
// namespace-uri with 0 arguments
|
// namespace-uri with 0 arguments
|
||||||
CHECK_XPATH_STRING(c, STR("namespace-uri()"), STR(""));
|
CHECK_XPATH_STRING(c, STR("namespace-uri()"), STR(""));
|
||||||
CHECK_XPATH_STRING(n.child(STR("c2")).child(STR("foo:child")), STR("namespace-uri()"), STR("http://foo2"));
|
CHECK_XPATH_STRING(n.child(STR("c2")).child(STR("foo:child")), STR("namespace-uri()"), STR("http://foo2"));
|
||||||
|
|
||||||
// namespace-uri with 1 non-node-set argument
|
// namespace-uri with 1 non-node-set argument
|
||||||
CHECK_XPATH_FAIL(STR("namespace-uri(1)"));
|
CHECK_XPATH_FAIL(STR("namespace-uri(1)"));
|
||||||
|
|
||||||
@ -710,7 +710,7 @@ TEST_XML_FLAGS(xpath_nodeset_name, "<node xmlns:foo='http://foo'><c1>text</c1><c
|
|||||||
// name with 0 arguments
|
// name with 0 arguments
|
||||||
CHECK_XPATH_STRING(c, STR("name()"), STR(""));
|
CHECK_XPATH_STRING(c, STR("name()"), STR(""));
|
||||||
CHECK_XPATH_STRING(n, STR("name()"), STR("node"));
|
CHECK_XPATH_STRING(n, STR("name()"), STR("node"));
|
||||||
|
|
||||||
// name with 1 non-node-set argument
|
// name with 1 non-node-set argument
|
||||||
CHECK_XPATH_FAIL(STR("name(1)"));
|
CHECK_XPATH_FAIL(STR("name(1)"));
|
||||||
|
|
||||||
@ -733,7 +733,7 @@ TEST(xpath_function_arguments)
|
|||||||
|
|
||||||
// conversion to string
|
// conversion to string
|
||||||
CHECK_XPATH_NUMBER(c, STR("string-length(12)"), 2);
|
CHECK_XPATH_NUMBER(c, STR("string-length(12)"), 2);
|
||||||
|
|
||||||
// conversion to number
|
// conversion to number
|
||||||
CHECK_XPATH_NUMBER(c, STR("round('1.2')"), 1);
|
CHECK_XPATH_NUMBER(c, STR("round('1.2')"), 1);
|
||||||
CHECK_XPATH_NUMBER(c, STR("round('1.7')"), 2);
|
CHECK_XPATH_NUMBER(c, STR("round('1.7')"), 2);
|
||||||
@ -741,13 +741,13 @@ TEST(xpath_function_arguments)
|
|||||||
// conversion to boolean
|
// conversion to boolean
|
||||||
CHECK_XPATH_BOOLEAN(c, STR("not('1')"), false);
|
CHECK_XPATH_BOOLEAN(c, STR("not('1')"), false);
|
||||||
CHECK_XPATH_BOOLEAN(c, STR("not('')"), true);
|
CHECK_XPATH_BOOLEAN(c, STR("not('')"), true);
|
||||||
|
|
||||||
// conversion to node set
|
// conversion to node set
|
||||||
CHECK_XPATH_FAIL(STR("sum(1)"));
|
CHECK_XPATH_FAIL(STR("sum(1)"));
|
||||||
|
|
||||||
// expression evaluation
|
// expression evaluation
|
||||||
CHECK_XPATH_NUMBER(c, STR("round((2 + 2 * 2) div 4)"), 2);
|
CHECK_XPATH_NUMBER(c, STR("round((2 + 2 * 2) div 4)"), 2);
|
||||||
|
|
||||||
// empty expressions
|
// empty expressions
|
||||||
CHECK_XPATH_FAIL(STR("round(,)"));
|
CHECK_XPATH_FAIL(STR("round(,)"));
|
||||||
CHECK_XPATH_FAIL(STR("substring(,)"));
|
CHECK_XPATH_FAIL(STR("substring(,)"));
|
||||||
|
@ -63,7 +63,7 @@ TEST(xpath_operators_arithmetic_specials)
|
|||||||
CHECK_XPATH_STRING(c, STR("1 div 0 + 100"), STR("Infinity"));
|
CHECK_XPATH_STRING(c, STR("1 div 0 + 100"), STR("Infinity"));
|
||||||
CHECK_XPATH_STRING(c, STR("-1 div 0 + 100"), STR("-Infinity"));
|
CHECK_XPATH_STRING(c, STR("-1 div 0 + 100"), STR("-Infinity"));
|
||||||
CHECK_XPATH_STRING(c, STR("0 div 0 + 100"), STR("NaN"));
|
CHECK_XPATH_STRING(c, STR("0 div 0 + 100"), STR("NaN"));
|
||||||
|
|
||||||
// unary - and multiplication clarifications from recommendations errata
|
// unary - and multiplication clarifications from recommendations errata
|
||||||
CHECK_XPATH_STRING(c, STR("1 div -0"), STR("-Infinity"));
|
CHECK_XPATH_STRING(c, STR("1 div -0"), STR("-Infinity"));
|
||||||
CHECK_XPATH_STRING(c, STR("-1 div -0"), STR("Infinity"));
|
CHECK_XPATH_STRING(c, STR("-1 div -0"), STR("Infinity"));
|
||||||
@ -99,7 +99,7 @@ TEST(xpath_operators_logical)
|
|||||||
CHECK_XPATH_BOOLEAN(c, STR("true() and false()"), false);
|
CHECK_XPATH_BOOLEAN(c, STR("true() and false()"), false);
|
||||||
CHECK_XPATH_BOOLEAN(c, STR("false() and false()"), false);
|
CHECK_XPATH_BOOLEAN(c, STR("false() and false()"), false);
|
||||||
CHECK_XPATH_BOOLEAN(c, STR("false() and true()"), false);
|
CHECK_XPATH_BOOLEAN(c, STR("false() and true()"), false);
|
||||||
|
|
||||||
// boolean conversion
|
// boolean conversion
|
||||||
CHECK_XPATH_BOOLEAN(c, STR("1 or ''"), true);
|
CHECK_XPATH_BOOLEAN(c, STR("1 or ''"), true);
|
||||||
CHECK_XPATH_BOOLEAN(c, STR("1 and ''"), false);
|
CHECK_XPATH_BOOLEAN(c, STR("1 and ''"), false);
|
||||||
@ -225,7 +225,7 @@ TEST_XML(xpath_operators_equality_node_set_primitive, "<node><c1><v>1</v><v>-1</
|
|||||||
CHECK_XPATH_BOOLEAN(n, STR("c2/v != 1"), true);
|
CHECK_XPATH_BOOLEAN(n, STR("c2/v != 1"), true);
|
||||||
CHECK_XPATH_BOOLEAN(n, STR("1 != c2/v"), true);
|
CHECK_XPATH_BOOLEAN(n, STR("1 != c2/v"), true);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// node set vs string
|
// node set vs string
|
||||||
CHECK_XPATH_BOOLEAN(c, STR("x = '1'"), false);
|
CHECK_XPATH_BOOLEAN(c, STR("x = '1'"), false);
|
||||||
CHECK_XPATH_BOOLEAN(c, STR("x != '1'"), false);
|
CHECK_XPATH_BOOLEAN(c, STR("x != '1'"), false);
|
||||||
|
@ -261,7 +261,7 @@ TEST(xpath_variables_multiple_documents)
|
|||||||
|
|
||||||
CHECK(ns.size() == 3);
|
CHECK(ns.size() == 3);
|
||||||
CHECK(ns[0] != ns[1] && ns[0] != ns[2]);
|
CHECK(ns[0] != ns[1] && ns[0] != ns[2]);
|
||||||
|
|
||||||
xml_node n0 = doc.child(STR("node")), n1 = doc1.child(STR("node")), n2 = doc2.child(STR("node"));
|
xml_node n0 = doc.child(STR("node")), n1 = doc1.child(STR("node")), n2 = doc2.child(STR("node"));
|
||||||
|
|
||||||
CHECK(n0 == ns[0].node() || n0 == ns[1].node() || n0 == ns[2].node());
|
CHECK(n0 == ns[0].node() || n0 == ns[1].node() || n0 == ns[2].node());
|
||||||
|
@ -363,7 +363,7 @@ TEST_XML(xpath_xalan_math_8, "<k>0.0004</k>")
|
|||||||
CHECK_XPATH_NUMBER(doc, STR("number(4 div 10000)"), 0.0004);
|
CHECK_XPATH_NUMBER(doc, STR("number(4 div 10000)"), 0.0004);
|
||||||
|
|
||||||
// +0 works around extended precision in div on x86 (this is needed for some configurations in MinGW 3.4)
|
// +0 works around extended precision in div on x86 (this is needed for some configurations in MinGW 3.4)
|
||||||
CHECK_XPATH_BOOLEAN(doc, STR("(number(k) = (4 div 10000 + 0))"), true);
|
CHECK_XPATH_BOOLEAN(doc, STR("(number(k) = (4 div 10000 + 0))"), true);
|
||||||
CHECK_XPATH_NUMBER(doc, STR("number(0.0001 * 4)"), 0.0004);
|
CHECK_XPATH_NUMBER(doc, STR("number(0.0001 * 4)"), 0.0004);
|
||||||
CHECK_XPATH_BOOLEAN(doc, STR("(number(k) = (0.0001 * 4))"), true);
|
CHECK_XPATH_BOOLEAN(doc, STR("(number(k) = (0.0001 * 4))"), true);
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
struct xml_writer_string: public pugi::xml_writer
|
struct xml_writer_string: public pugi::xml_writer
|
||||||
{
|
{
|
||||||
std::string contents;
|
std::string contents;
|
||||||
|
|
||||||
virtual void write(const void* data, size_t size);
|
virtual void write(const void* data, size_t size);
|
||||||
|
|
||||||
std::string as_narrow() const;
|
std::string as_narrow() const;
|
||||||
|
Loading…
Reference in New Issue
Block a user