From 7e7153457722ff2272bf094cca5387bd2e2ebd71 Mon Sep 17 00:00:00 2001 From: "arseny.kapoulkine@gmail.com" Date: Sun, 29 Apr 2012 22:51:21 +0000 Subject: docs: Regenerated HTML documentation git-svn-id: http://pugixml.googlecode.com/svn/trunk@908 99668b35-9821-0410-8761-19e4c4f06640 --- docs/manual/access.html | 208 ++++++++++++++++++++++++++++++++++++++++++----- docs/manual/apiref.html | 182 ++++++++++++++++++++++++++++++++++++++--- docs/manual/changes.html | 104 ++++++++++++++++++++++-- docs/manual/dom.html | 70 +++++++++++++--- docs/manual/install.html | 88 +++++++++++++++++--- docs/manual/loading.html | 44 +++++++--- docs/manual/modify.html | 90 ++++++++++++++++++-- docs/manual/saving.html | 110 +++++++++++++++++++++---- docs/manual/toc.html | 17 ++-- docs/manual/xpath.html | 16 ++-- 10 files changed, 829 insertions(+), 100 deletions(-) (limited to 'docs/manual') diff --git a/docs/manual/access.html b/docs/manual/access.html index d4b38c2..dcb072d 100644 --- a/docs/manual/access.html +++ b/docs/manual/access.html @@ -4,15 +4,15 @@ Accessing document data - - + +
-pugixml 1.0 manual | +pugixml 1.2 manual | Overview | Installation | Document: @@ -35,11 +35,13 @@
Getting node data
Getting attribute data
Contents-based traversal functions
+
Range-based for-loop support
Traversing node/attribute lists via iterators
Recursive traversal with xml_tree_walker
Searching for nodes/attributes with predicates
+
Working with text contents
Miscellaneous functions

@@ -167,10 +169,11 @@ In this case, <description> node does not have a value, but instead has a child of type node_pcdata with value "This is a node". pugixml - provides two helper functions to parse such data: + provides several helper functions to parse such data:

const char_t* xml_node::child_value() const;
 const char_t* xml_node::child_value(const char_t* name) const;
+xml_text xml_node::text() const;
 

child_value() @@ -181,6 +184,12 @@ child with relevant type, or if the handle is null, child_value functions return empty string.

+

+ text() + returns a special object that can be used for working with PCDATA contents + in more complex cases than just retrieving the value; it is described in + Working with text contents sections. +

There is an example of using some of these functions at the end of the next section. @@ -201,26 +210,40 @@ In case the attribute handle is null, both functions return empty strings - they never return null pointers.

+

+ If you need a non-empty string if the attribute handle is null (for example, + you need to get the option value from XML attribute, but if it is not specified, + you need it to default to "sorted" + instead of ""), you + can use as_string accessor: +

+
const char_t* xml_attribute::as_string(const char_t* def = "") const;
+
+

+ It returns def argument if + the attribute handle is null. If you do not specify the argument, the function + is equivalent to value(). +

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:

-
int xml_attribute::as_int() const;
-unsigned int xml_attribute::as_uint() const;
-double xml_attribute::as_double() const;
-float xml_attribute::as_float() const;
-bool xml_attribute::as_bool() const;
+
int xml_attribute::as_int(int def = 0) const;
+unsigned int xml_attribute::as_uint(unsigned int def = 0) const;
+double xml_attribute::as_double(double def = 0) const;
+float xml_attribute::as_float(float def = 0) const;
+bool xml_attribute::as_bool(bool def = false) const;
 

as_int, as_uint, as_double and as_float convert attribute values to numbers. - If attribute handle is null or attribute value is empty, 0 - is returned. Otherwise, all leading whitespace characters are truncated, - and the remaining string is parsed as a decimal number (as_int - or as_uint) or as a floating - point number in either decimal or scientific form (as_double + If attribute handle is null or attribute value is empty, def + argument is returned (which is 0 by default). Otherwise, all leading whitespace + characters are truncated, and the remaining string is parsed as a decimal + number (as_int or as_uint) or as a floating point number + in either decimal or scientific form (as_double or as_float). Any extra characters are silently discarded, i.e. as_int will return 1 for string "1abc". @@ -241,10 +264,11 @@

as_bool converts attribute - value to boolean as follows: if attribute handle is null or attribute value - is empty, false is returned. - Otherwise, true is returned - if the first character is one of '1', 't', + value to boolean as follows: if attribute handle is null, def + argument is returned (which is false + by default). If attribute value is empty, false + is returned. Otherwise, true + is returned if the first character is one of '1', 't', 'T', 'y', 'Y'. This means that strings like "true" and "yes" are recognized @@ -347,6 +371,56 @@

+

+ If your C++ compiler supports range-based for-loop (this is a C++11 feature, + at the time of writing it's supported by Microsoft Visual Studio 11 Beta, + GCC 4.6 and Clang 3.0), you can use it to enumerate nodes/attributes. Additional + helpers are provided to support this; note that they are also compatible + with Boost Foreach, + and possibly other pre-C++11 foreach facilities. +

+
implementation-defined type xml_node::children() const;
+implementation-defined type xml_node::children(const char_t* name) const;
+implementation-defined type xml_node::attributes() const;
+
+

+ children function allows + you to enumerate all child nodes; children + function with name argument + allows you to enumerate all child nodes with a specific name; attributes function allows you to enumerate + all attributes of the node. Note that you can also use node object itself + in a range-based for construct, which is equivalent to using children(). +

+

+ This is an example of using these functions (samples/traverse_rangefor.cpp): +

+

+ +

+
for (pugi::xml_node tool: tools.children("Tool"))
+{
+    std::cout << "Tool:";
+
+    for (pugi::xml_attribute attr: tool.attributes())
+    {
+        std::cout << " " << attr.name() << "=" << attr.value();
+    }
+
+    for (pugi::xml_node child: tool.children())
+    {
+        std::cout << ", child " << child.name();
+    }
+
+    std::cout << std::endl;
+}
+
+

+

+
+
+

+ It is common to store data as text contents of some node - i.e. <node><description>This is a node</description></node>. + In this case, <description> node does not have a value, but instead + has a child of type node_pcdata with value + "This is a node". pugixml + provides a special class, xml_text, + to work with such data. Working with text objects to modify data is described + in the documentation for modifying document + data; this section describes the access interface of xml_text. +

+

+ You can get the text object from a node by using text() method: +

+
xml_text xml_node::text() const;
+
+

+ If the node has a type node_pcdata + or node_cdata, then the node + itself is used to return data; otherwise, a first child node of type node_pcdata or node_cdata + is used. +

+

+ You can check if the text object is bound to a valid PCDATA/CDATA node by + using it as a boolean value, i.e. if + (text) { ... + } or if + (!text) { ... + }. Alternatively you can check it + by using the empty() + method: +

+
bool xml_text::empty() const;
+
+

+ Given a text object, you can get the contents (i.e. the value of PCDATA/CDATA + node) by using the following function: +

+
const char_t* xml_text::get() const;
+
+

+ In case text object is empty, the function returns an empty string - it never + returns a null pointer. +

+

+ If you need a non-empty string if the text object is empty, or if the text + contents is actually a number or a boolean that is stored as a string, you + can use the following accessors: +

+
const char_t* xml_text::as_string(const char_t* def = "") const;
+int xml_text::as_int(int def = 0) const;
+unsigned int xml_text::as_uint(unsigned int def = 0) const;
+double xml_text::as_double(double def = 0) const;
+float xml_text::as_float(float def = 0) const;
+bool xml_text::as_bool(bool def = false) const;
+
+

+ All of the above functions have the same semantics as similar xml_attribute members: they return the + default argument if the text object is empty, they convert the text contents + to a target type using the same rules and restrictions. You can refer + to documentation for the attribute functions for details. +

+

+ xml_text is essentially a + helper class that operates on xml_node + values. It is bound to a node of type node_pcdata + or [node_cdata]. You can use the following function to retrieve this node: +

+
xml_node xml_text::data() const;
+
+

+ Essentially, assuming text + is an xml_text object, callling + text.get() is + equivalent to calling text.data().value(). +

+

+ This is an example of using xml_text + object (samples/text.cpp): +

+

+ +

+
std::cout << "Project name: " << project.child("name").text().get() << std::endl;
+std::cout << "Project version: " << project.child("version").text().as_double() << std::endl;
+std::cout << "Project visibility: " << (project.child("public").text().as_bool(/* def= */ true) ? "public" : "private") << std::endl;
+std::cout << "Project description: " << project.child("description").text().get() << std::endl;
+
+

+

+
+
+

@@ -698,7 +866,7 @@

- @@ -706,7 +874,7 @@
-pugixml 1.0 manual | +pugixml 1.2 manual | Overview | Installation | Document: diff --git a/docs/manual/apiref.html b/docs/manual/apiref.html index 5737c51..cf1a137 100644 --- a/docs/manual/apiref.html +++ b/docs/manual/apiref.html @@ -4,15 +4,15 @@ API Reference - - + +
-pugixml 1.0 manual | +pugixml 1.2 manual | Overview | Installation | Document: @@ -60,6 +60,18 @@
  • #define PUGIXML_FUNCTION
  • +
  • + #define PUGIXML_MEMORY_PAGE_SIZE +
  • +
  • + #define PUGIXML_MEMORY_OUTPUT_STACK +
  • +
  • + #define PUGIXML_MEMORY_XPATH_PAGE_SIZE +
  • +
  • + #define PUGIXML_HEADER_ONLY +
  • Types: @@ -199,7 +211,10 @@ encoding_utf32

  • - encoding_wchar

    + encoding_wchar +
  • +
  • + encoding_latin1

  • @@ -241,9 +256,15 @@
  • format_no_declaration
  • +
  • + format_no_escapes +
  • format_raw
  • +
  • + format_save_file_text +
  • format_write_bom

    @@ -286,6 +307,9 @@
  • parse_ws_pcdata
  • +
  • + parse_ws_pcdata_single +
  • parse_wconv_attribute
  • @@ -364,20 +388,38 @@
  • - int as_int() const; + const char_t* as_string(const char_t* + def = + "") + const; +
  • +
  • + int as_int(int def = + 0) + const;
  • unsigned int - as_uint() const; + as_uint(unsigned + int def + = 0) const;
  • - double as_double() const; + double as_double(double + def = + 0) + const;
  • - float as_float() const; + float as_float(float def = + 0) + const;
  • - bool as_bool() const;

    + bool as_bool(bool def = + false) + const; +

  • @@ -517,6 +559,18 @@
  • xml_attribute last_attribute() const;

    +
  • +
  • + implementation-defined type children() const; +
  • +
  • + implementation-defined type children(const char_t* + name) + const; +
  • +
  • + implementation-defined type attributes() const;

    +
  • xml_node child(const char_t* @@ -557,7 +611,9 @@ const char_t* child_value(const char_t* name) const; -

    +
  • +
  • + xml_text text() const;

  • @@ -1023,6 +1079,108 @@
  • +
  • + class xml_text +
      +
    • + bool empty() const; +
    • +
    • + operator xml_text::unspecified_bool_type() const;

      + +
    • +
    • + const char_t* xml_text::get() const;

      + +
    • +
    • + const char_t* as_string(const char_t* + def = + "") + const; +
    • +
    • + int as_int(int def = + 0) + const; +
    • +
    • + unsigned int + as_uint(unsigned + int def + = 0) const; +
    • +
    • + double as_double(double + def = + 0) + const; +
    • +
    • + float as_float(float def = + 0) + const; +
    • +
    • + bool as_bool(bool def = + false) + const; +

      + +
    • +
    • + bool set(const char_t* + rhs); +

      + +
    • +
    • + bool set(int rhs); +
    • +
    • + bool set(unsigned + int rhs); +
    • +
    • + bool set(double + rhs); +
    • +
    • + bool set(bool rhs); +

      + +
    • +
    • + xml_text& + operator=(const char_t* + rhs); +
    • +
    • + xml_text& + operator=(int rhs); +
    • +
    • + xml_text& + operator=(unsigned + int rhs); +
    • +
    • + xml_text& + operator=(double + rhs); +
    • +
    • + xml_text& + operator=(bool rhs); +

      + +
    • +
    • + xml_node data() const;

      + +
    • +
    +
  • class xml_writer
    • @@ -1371,7 +1529,7 @@
    - @@ -1379,7 +1537,7 @@
    -pugixml 1.0 manual | +pugixml 1.2 manual | Overview | Installation | Document: diff --git a/docs/manual/changes.html b/docs/manual/changes.html index 78cde23..d119532 100644 --- a/docs/manual/changes.html +++ b/docs/manual/changes.html @@ -4,15 +4,15 @@ Changelog - - + +
    -pugixml 1.0 manual | +pugixml 1.2 manual | Overview | Installation | Document: @@ -30,6 +30,100 @@ +
    + 1.05.2012 - version + 1.2 +
    +

    + Major release, featuring header-only mode, various interface enhancements (i.e. + PCDATA manipulation and C++11 iteration), many other features and compatibility + improvements. +

    +
      +
    • + New features: +
        +
      1. + Added xml_text helper class for working with PCDATA/CDATA contents + of an element node +
      2. +
      3. + Added optional header-only mode (controlled by PUGIXML_HEADER_ONLY + define) +
      4. +
      5. + Added xml_node::children() and xml_node::attributes() for C++11 ranged + for loop or BOOST_FOREACH +
      6. +
      7. + Added support for Latin-1 (ISO-8859-1) encoding conversion during + loading and saving +
      8. +
      9. + Added custom default values for xml_attribute::as_* (they are returned if the attribute + does not exist) +
      10. +
      11. + Added parse_ws_pcdata_single flag for preserving whitespace-only + PCDATA in case it's the only child +
      12. +
      13. + Added format_save_file_text for xml_document::save_file to open files + as text instead of binary (changes newlines on Windows) +
      14. +
      15. + Added format_no_escapes flag to disable special symbol escaping (complements + ~parse_escapes) +
      16. +
      17. + Added support for loading document from streams that do not support + seeking +
      18. +
      19. + Added PUGIXML_MEMORY_* constants for tweaking allocation behavior (useful for embedded + systems) +
      20. +
      21. + Added PUGIXML_VERSION preprocessor define +
      22. +
      +
    • +
    • + Compatibility improvements: +
        +
      1. + Parser does not require setjmp support (improves compatibility with + some embedded platforms, enables clr:pure compilation) +
      2. +
      3. + STL forward declarations are no longer used (fixes SunCC/RWSTL compilation, + fixes clang compilation in C++11 mode) +
      4. +
      5. + Fixed AirPlay SDK, Android, Windows Mobile (WinCE) and C++/CLI compilation +
      6. +
      7. + Fixed several compilation warnings for various GCC versions, Intel + C++ compiler and Clang +
      8. +
      +
    • +
    • + Bug fixes: +
        +
      1. + Fixed unsafe bool conversion to avoid problems on C++/CLI +
      2. +
      3. + Iterator dereference operator is const now (fixes Boost filter_iterator + support) +
      4. +
      5. + xml_document::save_file now checks for file I/O errors during saving +
      6. +
      +
    • +
    1.11.2010 - version 1.0 @@ -760,7 +854,7 @@ - @@ -768,7 +862,7 @@
    -pugixml 1.0 manual | +pugixml 1.2 manual | Overview | Installation | Document: diff --git a/docs/manual/dom.html b/docs/manual/dom.html index 22509a9..22d8d83 100644 --- a/docs/manual/dom.html +++ b/docs/manual/dom.html @@ -4,15 +4,15 @@ Document object model - - + +
    -pugixml 1.0 manual | +pugixml 1.2 manual | Overview | Installation | Document: @@ -40,6 +40,7 @@
    Custom memory allocation/deallocation functions
    +
    Memory consumption tuning
    Document memory management internals
    @@ -102,16 +103,17 @@
    • Plain character data nodes (node_pcdata) represent plain text in XML. PCDATA nodes have a value, but do not have - a name or children/attributes. Note that plain character data is not - a part of the element node but instead has its own node; for example, - an element node can have several child PCDATA nodes. The example XML - representation of text nodes is as follows: + a name or children/attributes. Note that plain + character data is not a part of the element node but instead has its + own node; an element node can have several child PCDATA nodes. + The example XML representation of text nodes is as follows:
    <node> text1 <child/> text2 </node>
     

    Here "node" element - has three children, two of which are PCDATA nodes with values "text1" and "text2". + has three children, two of which are PCDATA nodes with values " text1 " and " + text2 ".

    • Character data nodes (node_cdata) represent @@ -617,6 +619,54 @@
    +

    + There are several important buffering optimizations in pugixml that rely + on predefined constants. These constants have default values that were + tuned for common usage patterns; for some applications, changing these + constants might improve memory consumption or increase performance. Changing + these constants is not recommended unless their default values result in + visible problems. +

    +

    + These constants can be tuned via configuration defines, as discussed in + Additional configuration + options; it is recommended to set them in pugiconfig.hpp. +

    +
      +
    • + PUGIXML_MEMORY_PAGE_SIZE + controls the page size for document memory allocation. Memory for node/attribute + objects is allocated in pages of the specified size. The default size + is 32 Kb; for some applications the size is too large (i.e. embedded + systems with little heap space or applications that keep lots of XML + documents in memory). A minimum size of 1 Kb is recommended.

      + +
    • +
    • + PUGIXML_MEMORY_OUTPUT_STACK + controls the cumulative stack space required to output the node. Any + output operation (i.e. saving a subtree to file) uses an internal buffering + scheme for performance reasons. The default size is 10 Kb; if you're + using node output from threads with little stack space, decreasing + this value can prevent stack overflows. A minimum size of 1 Kb is recommended. +

      + +
    • +
    • + PUGIXML_MEMORY_XPATH_PAGE_SIZE + controls the page size for XPath memory allocation. Memory for XPath + query objects as well as internal memory for XPath evaluation is allocated + in pages of the specified size. The default size is 4 Kb; if you have + a lot of resident XPath query objects, you might need to decrease the + size to improve memory consumption. A minimum size of 256 bytes is + recommended. +
    • +
    +
    + - @@ -665,7 +715,7 @@
    -pugixml 1.0 manual | +pugixml 1.2 manual | Overview | Installation | Document: diff --git a/docs/manual/install.html b/docs/manual/install.html index 9809a39..df7b322 100644 --- a/docs/manual/install.html +++ b/docs/manual/install.html @@ -4,15 +4,15 @@ Installation - - - + + +
    -pugixml 1.0 manual | +pugixml 1.2 manual | Overview | Installation | Document: @@ -44,6 +44,8 @@ a standalone static library
    Building pugixml as a standalone shared library
    +
    Using pugixml in header-only + mode
    Additional configuration options
    @@ -65,8 +67,8 @@ You can download the latest source distribution via one of the following links:

    -
    http://pugixml.googlecode.com/files/pugixml-1.0.zip
    -http://pugixml.googlecode.com/files/pugixml-1.0.tar.gz
    +
    http://pugixml.googlecode.com/files/pugixml-1.2.zip
    +http://pugixml.googlecode.com/files/pugixml-1.2.tar.gz
     

    The distribution contains library source, documentation (the manual you're @@ -94,7 +96,7 @@

    For example, to checkout the current version, you can use this command:

    -
    svn checkout http://pugixml.googlecode.com/svn/tags/release-1.0 pugixml
    +
    svn checkout http://pugixml.googlecode.com/svn/tags/release-1.2 pugixml

    To checkout the latest version, you can use this command:

    @@ -269,6 +271,58 @@

    +
    + +

    + It's possible to use pugixml in header-only mode. This means that all source + code for pugixml will be included in every translation unit that includes + pugixml.hpp. This is how most of Boost and STL libraries work. +

    +

    + Note that there are advantages and drawbacks of this approach. Header mode + may improve tree traversal/modification performance (because many simple + functions will be inlined), if your compiler toolchain does not support + link-time optimization, or if you have it turned off (with link-time optimization + the performance should be similar to non-header mode). However, since compiler + now has to compile pugixml source once for each translation unit that includes + it, compilation times may increase noticeably. If you want to use pugixml + in header mode but do not need XPath support, you can consider disabling + it by using PUGIXML_NO_XPATH define + to improve compilation time. +

    +

    + Enabling header-only mode is a two-step process: +

    +
      +
    1. + You have to define PUGIXML_HEADER_ONLY +
    2. +
    3. + You have to include pugixml.cpp whenever you include pugixml.hpp +
    4. +
    +

    + Both of these are best done via pugiconfig.hpp like this: +

    +
    #define PUGIXML_HEADER_ONLY
    +#include "pugixml.cpp"
    +
    +

    + Note that it is safe to compile pugixml.cpp if PUGIXML_HEADER_ONLY + is defined - so if you want to i.e. use header-only mode only in Release + configuration, you can include pugixml.cpp in your project (see Building pugixml as + a part of another static library/executable), + and conditionally enable header-only mode in pugiconfig.hpp, i.e.: +

    +
    #ifndef _DEBUG
    +    #define PUGIXML_HEADER_ONLY
    +    #include "pugixml.cpp"
    +#endif
    +
    +
    +

    + PUGIXML_MEMORY_PAGE_SIZE, PUGIXML_MEMORY_OUTPUT_STACK + and 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 Memory consumption tuning. +

    @@ -367,7 +427,8 @@
  • Microsoft Visual C++ 6.0, 7.0 (2002), 7.1 (2003), 8.0 (2005) x86/x64, - 9.0 (2008) x86/x64, 10.0 (2010) x86/x64 + 9.0 (2008) x86/x64, 10.0 (2010) x86/x64, 11.0 x86/x64/ARM and some + CLR versions
  • MinGW (GCC) 3.4, 4.4, 4.5, 4.6 x64 @@ -383,6 +444,9 @@
  • Apple MacOSX (GCC 4.0.1 x86/x64/PowerPC)
  • +
  • + Sun Solaris (sunCC x86/x64) +
  • Microsoft Xbox 360
  • @@ -395,6 +459,10 @@
  • Sony Playstation 3 (GCC 4.1.1, SNC 310.1)
  • +
  • + Various portable platforms (Android NDK, BlackBerry NDK, Samsung bada, + Windows CE) +
  • @@ -405,7 +473,7 @@
    - @@ -413,7 +481,7 @@
    -pugixml 1.0 manual | +pugixml 1.2 manual | Overview | Installation | Document: diff --git a/docs/manual/loading.html b/docs/manual/loading.html index 5b5576b..a26b62c 100644 --- a/docs/manual/loading.html +++ b/docs/manual/loading.html @@ -4,15 +4,15 @@ Loading document - - + +
    -pugixml 1.0 manual | +pugixml 1.2 manual | Overview | Installation | Document: @@ -282,10 +282,6 @@

    -

    - Stream loading requires working seek/tell functions and therefore may fail - when used with some stream implementations like gzstream. -

    @@ -384,7 +380,9 @@ returned by description() function may change from version to version, so any complex status handling should be based on status - value. + value. Note that description() returns a char + string even in PUGIXML_WCHAR_MODE; + you'll have to call as_wide to get the wchar_t string.

    If parsing failed because the source data was not a valid XML, the resulting @@ -533,6 +531,25 @@ " "), and only one child when parse_ws_pcdata is not set. This flag is off by default. +

    + + +

  • + parse_ws_pcdata_single determines + if whitespace-only PCDATA nodes that have no sibling nodes are to be + put in DOM tree. In some cases application needs to parse the whitespace-only + contents of nodes, i.e. <node> + </node>, but is not interested in whitespace + markup elsewhere. It is possible to use parse_ws_pcdata + flag in this case, but it results in excessive allocations and complicates + document processing in some cases; this flag is intended to avoid that. + As an example, after parsing XML string <node> + <a> </a> </node> with parse_ws_pcdata_single + flag set, <node> element will have one child <a>, and <a> + element will have one child with type node_pcdata + and value " ". + This flag has no effect if parse_ws_pcdata + is enabled. This flag is off by default.
  • @@ -581,8 +598,7 @@ attributes. This means, that after attribute values are normalized as if parse_wconv_attribute was set, leading and trailing space characters are removed, and all sequences - of space characters are replaced by a single space character. The value - of parse_wconv_attribute + of space characters are replaced by a single space character. parse_wconv_attribute has no effect if this flag is on. This flag is off by default. @@ -755,6 +771,10 @@ or encoding_utf32, depending on wchar_t size. +

  • + encoding_latin1 corresponds to ISO-8859-1 + encoding (also known as Latin-1). +
  • The algorithm used for encoding_auto @@ -828,7 +848,7 @@

    - @@ -836,7 +856,7 @@
    -pugixml 1.0 manual | +pugixml 1.2 manual | Overview | Installation | Document: diff --git a/docs/manual/modify.html b/docs/manual/modify.html index 3db02e1..b039dc7 100644 --- a/docs/manual/modify.html +++ b/docs/manual/modify.html @@ -4,15 +4,15 @@ Modifying document data - - + +
    -pugixml 1.0 manual | +pugixml 1.2 manual | Overview | Installation | Document: @@ -35,6 +35,7 @@
    Setting attribute data
    Adding nodes/attributes
    Removing nodes/attributes
    +
    Working with text contents
    Cloning nodes/attributes

    @@ -406,6 +407,85 @@

    +

    + pugixml provides a special class, xml_text, + to work with text contents stored as a value of some node, i.e. <node><description>This is a node</description></node>. + Working with text objects to retrieve data is described in the + documentation for accessing document data; this section describes + the modification interface of xml_text. +

    +

    + Once you have an xml_text + object, you can set the text contents using the following function: +

    +
    bool xml_text::set(const char_t* rhs);
    +
    +

    + This function tries to set the contents to the specified string, and returns + the operation result. The operation fails if the text object was retrieved + from a node that can not have a value and that is not an element node (i.e. + it is a node_declaration node), if + the text object is empty, or if there is insufficient memory to handle the + request. The provided string is copied into document managed memory and can + be destroyed after the function returns (for example, you can safely pass + stack-allocated buffers to this function). Note that if the text object was + retrieved from an element node, this function creates the PCDATA child node + if necessary (i.e. if the element node does not have a PCDATA/CDATA child + already). +

    +

    + In addition to a string function, several functions are provided for handling + text with numbers and booleans as contents: +

    +
    bool xml_text::set(int rhs);
    +bool xml_text::set(unsigned int rhs);
    +bool xml_text::set(double rhs);
    +bool xml_text::set(bool 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 refer to documentation + for the attribute functions for details. +

    +

    + For convenience, all set + functions have the corresponding assignment operators: +

    +
    xml_text& xml_text::operator=(const char_t* rhs);
    +xml_text& xml_text::operator=(int rhs);
    +xml_text& xml_text::operator=(unsigned int rhs);
    +xml_text& xml_text::operator=(double rhs);
    +xml_text& xml_text::operator=(bool rhs);
    +
    +

    + These operators simply call the right set + function and return the attribute they're called on; the return value of + set is ignored, so errors + are ignored. +

    +

    + This is an example of using xml_text + object to modify text contents (samples/text.cpp): +

    +

    + +

    +
    // change project version
    +project.child("version").text() = 1.2;
    +
    +// add description element and set the contents
    +// note that we do not have to explicitly add the node_pcdata child
    +project.append_child("description").text().set("a test project");
    +
    +

    +

    +
    +
    +

    @@ -528,7 +608,7 @@

    - @@ -536,7 +616,7 @@
    -pugixml 1.0 manual | +pugixml 1.2 manual | Overview | Installation | Document: diff --git a/docs/manual/saving.html b/docs/manual/saving.html index abaf9f2..2be70cb 100644 --- a/docs/manual/saving.html +++ b/docs/manual/saving.html @@ -4,15 +4,15 @@ Saving document - - + +
    -pugixml 1.0 manual | +pugixml 1.2 manual | Overview | Installation | Document: @@ -37,6 +37,7 @@
    Saving a single subtree
    Output options
    Encodings
    +
    Customizing document declaration

    Often after creating a new document or loading the existing one and processing @@ -52,8 +53,9 @@

    Before writing to the destination the node/attribute data is properly formatted according to the node type; all special XML symbols, such as < and &, - are properly escaped. In order to guard against forgotten node/attribute names, - empty node/attribute names are printed as ":anonymous". + are properly escaped (unless format_no_escapes + flag is set). In order to guard against forgotten node/attribute names, empty + node/attribute names are printed as ":anonymous". For well-formed output, make sure all node and attribute names are set to meaningful values.

    @@ -179,11 +181,11 @@

    In order to output the document via some custom transport, for example sockets, - you should create an object which implements xml_writer_file + you should create an object which implements xml_writer interface and pass it to save - function. xml_writer_file::write - function is called with a buffer as an input, where data - points to buffer start, and size + function. xml_writer::write function is called with a buffer + as an input, where data points + to buffer start, and size is equal to the buffer size in bytes. write implementation must write the buffer to the transport; it can not save the passed buffer pointer, as the buffer contents will change after write returns. The buffer contains the @@ -192,9 +194,8 @@

    write function is called with relatively large blocks (size is usually several kilobytes, except for - the first block with BOM, which is output only if format_write_bom - is set, and last block, which may be small), so there is often no need for - additional buffering in the implementation. + the last block that may be small), so there is often no need for additional + buffering in the implementation.

    This is a simple example of custom writer for saving document data to STL @@ -310,7 +311,19 @@ to be read by humans; also it can be useful if the document was parsed with parse_ws_pcdata flag, to preserve the original document formatting as much as possible. This flag - is off by default. + is off by default.

    + + +

  • + format_no_escapes disables output + escaping for attribute values and PCDATA contents. If this flag is on, + special symbols (', &, <, >) and all non-printable characters + (those with codepoint values less than 32) are converted to XML escape + sequences (i.e. &amp;) during output. If this flag is off, no text + processing is performed; therefore, output XML can be malformed if output + contents contains invalid symbols (i.e. having a stray < in the PCDATA + will make the output malformed). This flag is on + by default.
  • @@ -337,6 +350,16 @@ functions: they never output the BOM. This flag is off by default. +

  • + format_save_file_text changes + the file mode when using save_file + function. By default, file is opened in binary mode, which means that + the output file will contain platform-independent newline \n (ASCII 10). + If this flag is on, file is opened in text mode, which on some systems + changes the newline format (i.e. on Windows you can use this flag to + output XML documents with \r\n (ASCII 13 10) newlines. This flag is + off by default. +
  • Additionally, there is one predefined option mask: @@ -435,10 +458,67 @@

    +
    + +

    + When you are saving the document using xml_document::save() or xml_document::save_file(), a default XML document declaration is + output, if format_no_declaration + is not speficied and if the document does not have a declaration node. However, + the default declaration is not customizable. If you want to customize the + declaration output, you need to create the declaration node yourself. +

    +
    + + + + + +
    [Note]Note

    + By default the declaration node is not added to the document during parsing. + If you just need to preserve the original declaration node, you have to + add the flag parse_declaration + to the parsing flags; the resulting document will contain the original + declaration node, which will be output during saving. +

    +

    + Declaration node is a node with type node_declaration; + it behaves like an element node in that it has attributes with values (but + it does not have child nodes). Therefore setting custom version, encoding + or standalone declaration involves adding attributes and setting attribute + values. +

    +

    + This is an example that shows how to create a custom declaration node (samples/save_declaration.cpp): +

    +

    + +

    +
    // get a test document
    +pugi::xml_document doc;
    +doc.load("<foo bar='baz'><call>hey</call></foo>");
    +
    +// add a custom declaration node
    +pugi::xml_node decl = doc.prepend_child(pugi::node_declaration);
    +decl.append_attribute("version") = "1.0";
    +decl.append_attribute("encoding") = "UTF-8";
    +decl.append_attribute("standalone") = "no";
    +
    +// <?xml version="1.0" encoding="UTF-8" standalone="no"?> 
    +// <foo bar="baz">
    +//         <call>hey</call>
    +// </foo>
    +doc.save(std::cout);
    +std::cout << std::endl;
    +
    +

    +

    +
    - @@ -446,7 +526,7 @@
    -pugixml 1.0 manual | +pugixml 1.2 manual | Overview | Installation | Document: diff --git a/docs/manual/toc.html b/docs/manual/toc.html index 97d0b6c..d9fe5f8 100644 --- a/docs/manual/toc.html +++ b/docs/manual/toc.html @@ -4,14 +4,14 @@ Table of Contents - - + +
    -pugixml 1.0 manual | +pugixml 1.2 manual | Overview | Installation | Document: @@ -52,6 +52,8 @@ a standalone static library
    Building pugixml as a standalone shared library
    +
    Using pugixml in header-only + mode
    Additional configuration options
    @@ -68,6 +70,7 @@
    Custom memory allocation/deallocation functions
    +
    Memory consumption tuning
    Document memory management internals
    @@ -88,11 +91,13 @@
    Getting node data
    Getting attribute data
    Contents-based traversal functions
    +
    Range-based for-loop support
    Traversing node/attribute lists via iterators
    Recursive traversal with xml_tree_walker
    Searching for nodes/attributes with predicates
    +
    Working with text contents
    Miscellaneous functions
    Modifying document data
    @@ -101,6 +106,7 @@
    Setting attribute data
    Adding nodes/attributes
    Removing nodes/attributes
    +
    Working with text contents
    Cloning nodes/attributes
    Saving document
    @@ -111,6 +117,7 @@
    Saving a single subtree
    Output options
    Encodings
    +
    Customizing document declaration
    XPath
    @@ -128,7 +135,7 @@ - @@ -136,7 +143,7 @@
    -pugixml 1.0 manual | +pugixml 1.2 manual | Overview | Installation | Document: diff --git a/docs/manual/xpath.html b/docs/manual/xpath.html index ea6b956..bb37f64 100644 --- a/docs/manual/xpath.html +++ b/docs/manual/xpath.html @@ -4,15 +4,15 @@ XPath - - + +
    -pugixml 1.0 manual | +pugixml 1.2 manual | Overview | Installation | Document: @@ -624,7 +624,11 @@

    description() member function can be used to get the error message; it never returns the - null pointer, so you can safely use description() even if query parsing succeeded. + null pointer, so you can safely use description() even if query parsing succeeded. Note that + description() + returns a char string even in + PUGIXML_WCHAR_MODE; you'll + have to call as_wide to get the wchar_t string.

    In addition to the error message, parsing result has an offset @@ -717,7 +721,7 @@ - @@ -725,7 +729,7 @@
    -pugixml 1.0 manual | +pugixml 1.2 manual | Overview | Installation | Document: -- cgit v1.2.3