From f0e0fb5f3f2af8b695680e84572137660ffd835b Mon Sep 17 00:00:00 2001
From: Karen Arutyunov In this chapter we will examine how to parse a very simple XML
document using the XSD-generated C++/Parser skeletons.
The code presented in this chapter is based on the examples/cxx/parser/
directory in the XSD
- distribution contains a collection of examples and a README
- file with an overview of each example.cxx/parser/
directory in the
+ xsd-examples package
+ contains a collection of examples and a README file with an overview
+ of each example.README
file in the XSD distribution explains
- how to compile the examples on various platforms.README
file in the
+ xsd-examples package
+ explains how to build the examples.hello
- example which can be found in the examples/cxx/parser/
- directory of the XSD distribution.cxx/parser/
directory in
+ the xsd-examples
+ package.
-$ xsd cxx-parser --xml-parser expat hello.xsd +$ xsd cxx-parser --std c++11 --xml-parser expat hello.xsd
The --xml-parser
option indicates that we want to
@@ -754,8 +757,8 @@ main (int argc, char* argv[])
on these options refer to the
XSD
Compiler Command Line Manual. The 'generated'
example
- in the XSD distribution shows the sample implementation generation
- feature in action.
-$ c++ -I.../libxsd -c driver.cxx hello-pskel.cxx -$ c++ -o driver driver.o hello-pskel.o -lexpat +$ c++ -std=c++11 -I.../libxsd -c driver.cxx hello-pskel.cxx +$ c++ -std=c++11 -o driver driver.o hello-pskel.o -lexpat $ ./driver hello.xml Hello, sun! Hello, moon! @@ -776,9 +779,10 @@ Hello, world!
Here .../libxsd
represents the path to the
- libxsd
directory in the XSD distribution.
- We can also test the error handling. To test XML well-formedness
- checking, we can try to parse hello-pskel.hxx
:
hello-pskel.hxx
:
$ ./driver hello-pskel.hxx @@ -1490,7 +1494,7 @@ gender ::gender ::gender; option to let the XSD compiler know about our type map:-$ xsd cxx-parser --type-map people.map people.xsd +$ xsd cxx-parser --std c++11 --type-map people.map people.xsdIf we now look at the generated
@@ -1738,7 +1742,8 @@ people ::people; recompile our schema and move on to implementing the parsers:people-pskel.hxx
, @@ -1618,9 +1622,9 @@ namespace http://www.example.com/xmlns/mystd::wstring
depending on the character type selected (see Section 5.2, "Character Type and Encoding" for more information). The binary XML Schema - types are mapped to eitherstd::auto_ptr<xml_schema::buffer>
- orstd::unique_ptr<xml_schema::buffer>
- depending on the C++ standard selected (C++98 or C++11, + types are mapped to eitherstd::unique_ptr<xml_schema::buffer>
+ orstd::auto_ptr<xml_schema::buffer>
+ depending on the C++ standard selected (C++11 or C++98, respectively; refer to the--std
XSD compiler command line option for details).-$ xsd cxx-parser --xml-parser expat --type-map people.map people.xsd +$ xsd cxx-parser --std c++11 --xml-parser expat --type-map people.map \ + people.xsdHere is the implementation of our three parsers in full. One @@ -1882,8 +1887,8 @@ main (int argc, char* argv[])
-$ c++ -I.../libxsd -c driver.cxx people-pskel.cxx -$ c++ -o driver driver.o people-pskel.o -lexpat +$ c++ -std=c++11 -I.../libxsd -c driver.cxx people-pskel.cxx +$ c++ -std=c++11 -o driver driver.o people-pskel.o -lexpat $ ./driver people.xml first: John last: Doe @@ -1917,12 +1922,12 @@ age: 285.1 C++ Standard
-The C++/Parser mapping provides support for ISO/IEC C++ 1998/2003 (C++98) - and ISO/IEC C++ 2011 (C++11). To select the C++ standard for the +
The C++/Parser mapping provides support for ISO/IEC C++ 2011 (C++11) + and ISO/IEC C++ 1998/2003 (C++98). To select the C++ standard for the generated code we use the
+ C++11, the document explains the C++11/98 usage difference and so + they can easily be converted to C++98.--std
XSD compiler command line option. While the majority of the examples in this guide use - C++98, support for the new functionality and library components - introduced in C++11 are discussed throughout the document.5.2 Character Type and Encoding
@@ -2354,9 +2359,10 @@ private:Most of code presented in this section is taken from the
@@ -2754,8 +2760,8 @@ namespace xml_schemapolymorphism
example which can be found in the -examples/cxx/parser/
directory of the XSD distribution. - Handling ofxsi:type
and substitution groups when used - on root elements requires a number of special actions as shown in +cxx/parser/
directory in the + xsd-examples package. + Handling ofxsi:type
and substitution groups when used on + root elements requires a number of special actions as shown in thepolyroot
example.The return type of the
diff --git a/xsd/doc/cxx/tree/guide/index.xhtml.in b/xsd/doc/cxx/tree/guide/index.xhtml.in index e1bb36e..b704e50 100644 --- a/xsd/doc/cxx/tree/guide/index.xhtml.in +++ b/xsd/doc/cxx/tree/guide/index.xhtml.in @@ -305,12 +305,14 @@base64_binary_pimpl
andhex_binary_pimpl
parser implementations is either -std::auto_ptr<xml_schema::buffer>
(C++98) or -std::unique_ptr<xml_schema::buffer>
(C++11), +std::unique_ptr<xml_schema::buffer>
(C++11) or +std::auto_ptr<xml_schema::buffer>
(C++98), depending on the C++ standard selected (--std
XSD compiler option). Thexml_schema::buffer
type represents a binary buffer and its interface is presented below.
examples/cxx/tree/
directory in the XSD
- distribution contains a collection of examples and a README
- file with an overview of each example.cxx/tree/
directory in the
+ xsd-examples package
+ contains a collection of examples and a README file with an overview
+ of each example.README
file in the XSD distribution explains
- how to compile the examples on various platforms.README
file in the
+ xsd-examples package
+ explains how to build the examples.hello
example which can be found in
- the examples/cxx/tree/
directory of the XSD
- distribution.
+ the cxx/tree/
directory in the
+ xsd-examples package.
-$ xsd cxx-tree hello.xsd +$ xsd cxx-tree --std c++11 hello.xsd
The XSD compiler produces two C++ files: hello.hxx
and
@@ -584,10 +586,10 @@ public:
};
-std::auto_ptr<hello_t>
+std::unique_ptr<hello_t>
hello (const std::string& uri);
-std::auto_ptr<hello_t>
+std::unique_ptr<hello_t>
hello (std::istream&);
@@ -625,22 +627,22 @@ hello (std::istream&);
with the --root-element-*
options). Parsing
functions return a dynamically allocated object model as an
automatic pointer. The actual pointer used depends on the
- C++ standard selected. For C++98 it is std::auto_ptr
- as shown above. For C++11 it is std::unique_ptr
.
+ C++ standard selected. For C++11 it is std::unique_ptr
+ as shown above. For C++98 it is std::auto_ptr
.
For example, if we modify our XSD compiler invocation to
- select C++11:
-$ xsd cxx-tree --std c++11 hello.xsd +$ xsd cxx-tree hello.xsd
Then the parsing function signatures will become:
-std::unique_ptr<hello_t> +std::auto_ptr<hello_t> hello (const std::string& uri); -std::unique_ptr<hello_t> +std::auto_ptr<hello_t> hello (std::istream&);@@ -664,7 +666,7 @@ main (int argc, char* argv[]) { try { - auto_ptr<hello_t> h (hello (argv[1])); + unique_ptr<hello_t> h (hello (argv[1])); for (hello_t::name_const_iterator i (h->name ().begin ()); i != h->name ().end (); @@ -701,8 +703,8 @@ main (int argc, char* argv[])
-$ c++ -I.../libxsd -c driver.cxx hello.cxx -$ c++ -o driver driver.o hello.o -lxerces-c +$ c++ -std=c++11 -I.../libxsd -c driver.cxx hello.cxx +$ c++ -std=c++11 -o driver driver.o hello.o -lxerces-c $ ./driver hello.xml Hello, sun! Hello, moon! @@ -710,10 +712,10 @@ Hello, world!
Here .../libxsd
represents the path to the
- libxsd
directory in the XSD distribution.
- Note also that we are required to link our application
- with the Xerces-C++ library because the generated code
- uses it as the underlying XML parser.
--generate-serialization
options:
-$ xsd cxx-tree --generate-serialization hello.xsd +$ xsd cxx-tree --std c++11 --generate-serialization hello.xsd
If we now examine the generated hello.hxx
file,
@@ -760,7 +762,7 @@ main (int argc, char* argv[])
{
try
{
- auto_ptr<hello_t> h (hello (argv[1]));
+ unique_ptr<hello_t> h (hello (argv[1]));
// Change the greeting phrase.
//
@@ -909,7 +911,7 @@ main (int argc, char* argv[])
change the type naming scheme:
-$ xsd cxx-tree --type-naming ucc hello.xsd +$ xsd cxx-tree --std c++11 --type-naming ucc hello.xsd
The ucc
argument to the --type-naming
@@ -959,10 +961,10 @@ public:
};
-std::auto_ptr<Hello_t>
+std::unique_ptr<Hello_t>
hello (const std::string& uri);
-std::auto_ptr<Hello_t>
+std::unique_ptr<Hello_t>
hello (std::istream&);
@@ -976,7 +978,8 @@ hello (std::istream&);
--type-regex
option:
-$ xsd cxx-tree --type-naming ucc --type-regex '/ (.+)_t/\u$1/' hello.xsd +$ xsd cxx-tree --std c++11 --type-naming ucc \ + --type-regex '/ (.+)_t/\u$1/' hello.xsd
This results in the following changes to the generated code:
@@ -1022,10 +1025,10 @@ public: }; -std::auto_ptr<Hello> +std::unique_ptr<Hello> hello (const std::string& uri); -std::auto_ptr<Hello> +std::unique_ptr<Hello> hello (std::istream&); @@ -1111,7 +1114,8 @@ hello (std::istream&); our schema with the--generate-doxygen
option:
-$ xsd cxx-tree --generate-serialization --generate-doxygen hello.xsd +$ xsd cxx-tree --std c++11 --generate-serialization --generate-doxygen \ + hello.xsd
Now the generated hello.hxx
file contains comments
@@ -1167,12 +1171,12 @@ $ doxygen hello.doxygen
The C++/Tree mapping provides support for ISO/IEC C++ 1998/2003 (C++98) - and ISO/IEC C++ 2011 (C++11). To select the C++ standard for the +
The C++/Tree mapping provides support for ISO/IEC C++ 2011 (C++11)
+ and ISO/IEC C++ 1998/2003 (C++98). To select the C++ standard for the
generated code we use the --std
XSD compiler command
line option. While the majority of the examples in this guide use
- C++98, support for the new functionality and library components
- introduced in C++11 are discussed throughout the document.
-// Add the John Doe record. C++98 version. -// -auto_ptr<person_t> john_p ( - new person_t ("John", // first-name - "Doe", // last-name - gender_t::male, // gender - 32, // age - 1)); -ps.push_back (john_p); // assumes ownership - // Add the Jane Doe record. C++11 version // unique_ptr<person_t> jane_p ( @@ -1892,6 +1886,16 @@ unique_ptr<person_t> jane_p ( 28, // age 2)); // id ps.push_back (std::move (jane_p)); // assumes ownership + +// Add the John Doe record. C++98 version. +// +auto_ptr<person_t> john_p ( + new person_t ("John", // first-name + "Doe", // last-name + gender_t::male, // gender + 32, // age + 1)); +ps.push_back (john_p); // assumes ownership
For more information on the non-copying modifier functions refer to @@ -2265,17 +2269,17 @@ ps.push_back (std::move (jane_p)); // assumes ownership on the following three parsing functions:
-std::[auto|unique]_ptr<people_t> +std::[unique|auto]_ptr<people_t> people (const std::string& uri, xml_schema::flags f = 0, const xml_schema::properties& p = xml_schema::properties ()); -std::[auto|unique]_ptr<people_t> +std::[unique|auto]_ptr<people_t> people (std::istream& is, xml_schema::flags f = 0, const xml_schema::properties& p = xml_schema::properties ()); -std::[auto|unique]_ptr<people_t> +std::[unique|auto]_ptr<people_t> people (std::istream& is, const std::string& resource_id, xml_schema::flags f = 0, @@ -2296,29 +2300,29 @@ people (std::istream& is, to pass additional information to the parsing functions. We will use these two arguments in Section 5.1, "XML Schema Validation and Searching" below. All three functions return - the object model as eitherstd::auto_ptr
(C++98) or -std::unique_ptr
(C++11), depending on the C++ standard + the object model as eitherstd::unique_ptr
(C++11) or +std::auto_ptr
(C++98), depending on the C++ standard selected (--std
XSD compiler option). The following example shows how we can use the above parsing functions:-using std::auto_ptr; +using std::unique_ptr; // Parse a local file or URI. // -auto_ptr<people_t> p1 (people ("people.xml")); -auto_ptr<people_t> p2 (people ("http://example.com/people.xml")); +unique_ptr<people_t> p1 (people ("people.xml")); +unique_ptr<people_t> p2 (people ("http://example.com/people.xml")); // Parse a local file via ifstream. // std::ifstream ifs ("people.xml"); -auto_ptr<people_t> p3 (people (ifs, "people.xml")); +unique_ptr<people_t> p3 (people (ifs, "people.xml")); // Parse an XML string. // std::string str ("..."); // XML in a string. std::istringstream iss (str); -auto_ptr<people_t> p4 (people (iss)); +unique_ptr<people_t> p4 (people (iss));@@ -2331,7 +2335,7 @@ auto_ptr<people_t> p4 (people (iss)); flag to the parsing functions, for example:-auto_ptr<people_t> p ( +unique_ptr<people_t> p ( people ("people.xml", xml_schema::flags::dont_validate));@@ -2373,7 +2377,7 @@ xml_schema::properties props; props.no_namespace_schema_location ("people.xsd"); props.schema_location ("http://www.w3.org/XML/1998/namespace", "xml.xsd"); -auto_ptr<people_t> p (people ("people.xml", 0, props)); +unique_ptr<people_t> p (people ("people.xml", 0, props));
The schema locations provided with this method overrides @@ -2405,7 +2409,7 @@ props.schema_location ( "http://www.w3.org/XML/1998/namespace", "file:///" + std::string (cwd) + "/xml.xsd"); -auto_ptr<people_t> p (people ("people.xml", 0, props)); +unique_ptr<people_t> p (people ("people.xml", 0, props));
A third method is the most useful if you are planning to parse
@@ -2414,14 +2418,16 @@ auto_ptr<people_t> p (people ("people.xml", 0, props));
the XML parser which can then be used to parse all documents
without re-parsing the schemas. For more information on
this method refer to the caching
example in the
- examples/cxx/tree/
directory of the XSD
- distribution. It is also possible to convert the schemas into
- a pre-compiled binary representation and embed this representation
- directly into the application executable. With this approach your
- application can perform XML Schema validation without depending on
- any external schema files. For more information on how to achieve
- this refer to the embedded
example in the
- examples/cxx/tree/
directory of the XSD distribution.
cxx/tree/
directory in the
+ xsd-examples package.
+ It is also possible to convert the schemas into a pre-compiled
+ binary representation and embed this representation directly into
+ the application executable. With this approach your application can
+ perform XML Schema validation without depending on any external
+ schema files. For more information on how to achieve this refer to
+ the embedded
example in the cxx/tree/
+ directory in the xsd-examples
+ package.
When the XML parser cannot locate a schema for the XML document, the validation fails and XML document @@ -2457,7 +2463,7 @@ people.xml:9:10 error: no declaration found for element 'age'
try { - auto_ptr<people_t> p (people ("people.xml")); + unique_ptr<people_t> p (people ("people.xml")); } catch (const xml_schema::exception& e) { @@ -2492,7 +2498,7 @@ if (ifs.fail ()) return 1; } -auto_ptr<people_t> p (people (ifs, "people.xml")); +unique_ptr<people_t> p (people (ifs, "people.xml")); if (ifs.fail ()) { @@ -2511,7 +2517,7 @@ try ifs.exceptions (std::ifstream::badbit | std::ifstream::failbit); ifs.open ("people.xml"); - auto_ptr<people_t> p (people (ifs, "people.xml")); + unique_ptr<people_t> p (people (ifs, "people.xml")); } catch (const std::ifstream::failure&) { diff --git a/xsd/doc/cxx/tree/manual/index.xhtml.in b/xsd/doc/cxx/tree/manual/index.xhtml.in index 48f36b6..5a7240a 100644 --- a/xsd/doc/cxx/tree/manual/index.xhtml.in +++ b/xsd/doc/cxx/tree/manual/index.xhtml.in @@ -469,12 +469,14 @@
examples/cxx/tree/
directory in the XSD
- distribution contains a collection of examples and a README
- file with an overview of each example.cxx/tree/
directory in the
+ xsd-examples package
+ contains a collection of examples and a README file with an overview
+ of each example.README
file in the XSD distribution explains
- how to compile the examples on various platforms.README
file in the
+ xsd-examples package
+ explains how to build the examples.The C++/Tree mapping provides support for ISO/IEC C++ 1998/2003 (C++98) - and ISO/IEC C++ 2011 (C++11). To select the C++ standard for the +
The C++/Tree mapping provides support for ISO/IEC C++ 2011 (C++11)
+ and ISO/IEC C++ 1998/2003 (C++98). To select the C++ standard for the
generated code we use the --std
XSD compiler command
- line option. While the majority of the examples in this manual use
- C++98, support for the new functionality and library components
- introduced in C++11 are discussed throughout the document.
push_back
and insert
member functions which instead of the constant reference
- to the element type accept automatic pointer (std::auto_ptr
- or std::unique_ptr
, depending on the C++ standard
+ to the element type accept automatic pointer (std::unique_ptr
+ or std::auto_ptr
, depending on the C++ standard
selected) to the element type. These functions assume ownership
of the pointed to object and reset the passed automatic pointer.
@@ -2412,8 +2414,8 @@ public:
sequences of non-fundamental C++ types is the addition of
the overloaded push_back
and insert
member functions which instead of the constant reference
- to the element type accept automatic pointer (std::auto_ptr
- or std::unique_ptr
, depending on the C++ standard
+ to the element type accept automatic pointer (std::unique_ptr
+ or std::auto_ptr
, depending on the C++ standard
selected) to the element type. These functions assume ownership
of the pointed to object and reset the passed automatic pointer.
@@ -2480,10 +2482,10 @@ public:
instance is initialized with copies of the passed objects. In the
second constructor, arguments that are complex types (that is,
they themselves contain elements or attributes) are passed as
- either std::auto_ptr
(C++98) or std::unique_ptr
- (C++11), depending on the C++ standard selected. In this case the newly
+ either std::unique_ptr
(C++11) or std::auto_ptr
+ (C++98), depending on the C++ standard selected. In this case the newly
created instance is directly initialized with and assumes ownership
- of the pointed to objects and the std::[auto|unique]_ptr
+ of the pointed to objects and the std::[unique|auto]_ptr
arguments are reset to 0
. For instance:
@@ -2529,7 +2531,7 @@ class object: public xml_schema::type { public: object (const bool& s_one, const complex& c_one); - object (const bool& s_one, std::[auto|unique]_ptr<complex> c_one); + object (const bool& s_one, std::[unique|auto]_ptr<complex> c_one); object (const object&); public: @@ -2546,7 +2548,7 @@ public:
Notice that the generated complex
class does not
- have the second (std::[auto|unique]_ptr
) version of the
+ have the second (std::[unique|auto]_ptr
) version of the
constructor since all its required members are of simple types.
If an XML Schema complex type has an ultimate base which is an XML
@@ -2817,8 +2819,8 @@ public:
constant of the member's type. It makes a deep copy of its argument.
Except for member's types that are mapped to fundamental C++ types,
the second modifier function is provided that expects an argument
- of type automatic pointer (std::auto_ptr
or
- std::unique_ptr
, depending on the C++ standard selected)
+ of type automatic pointer (std::unique_ptr
or
+ std::auto_ptr
, depending on the C++ standard selected)
to the member's type. It assumes ownership of the pointed to object
and resets the passed automatic pointer. For instance:
std::auto_ptr
or
- std::unique_ptr
, depending on the C++ standard selected)
+ of type automatic pointer (std::unique_ptr
or
+ std::auto_ptr
, depending on the C++ standard selected)
to the member's type. It assumes ownership of the pointed to object
and resets the passed automatic pointer. The last modifier function
expects an argument of type reference to constant of the container
@@ -2979,7 +2981,7 @@ public:
member (const member_type&);
void
- member (std::[auto|unique]_ptr<member_type>);
+ member (std::[unique|auto]_ptr<member_type>);
void
member (const member_optional&);
@@ -2992,7 +2994,7 @@ public:
The optional
class template is defined in an
implementation-specific namespace and has the following
- interface. The [auto|unique]_ptr
-based constructor
+ interface. The [unique|auto]_ptr
-based constructor
and modifier function are only available if the template
argument is not a fundamental C++ type.
detach_back
and detach
member functions. The additional push_back
and
insert
functions accept an automatic pointer
- (std::auto_ptr
or std::unique_ptr
,
+ (std::unique_ptr
or std::auto_ptr
,
depending on the C++ standard selected) to the
element type instead of the constant reference. They assume
ownership of the pointed to object and reset the passed
@@ -3244,17 +3246,17 @@ public:
...
void
- push_back (std::[auto|unique]_ptr<X>)
+ push_back (std::[unique|auto]_ptr<X>)
iterator
- insert (iterator position, std::[auto|unique]_ptr<X>)
+ insert (iterator position, std::[unique|auto]_ptr<X>)
- std::[auto|unique]_ptr<X>
+ std::[unique|auto]_ptr<X>
detach_back (bool pop = true);
iterator
detach (iterator position,
- std::[auto|unique]_ptr<X>& result,
+ std::[unique|auto]_ptr<X>& result,
bool erase = true)
...
@@ -3282,13 +3284,6 @@ f (object& o)
//
s.push_back ("hello"); // deep copy
- // C++98 version.
- //
- std::auto_ptr<string> p (new string ("hello"));
- s.push_back (p); // assumes ownership
- p = s.detach_back (); // detach and pop
- s.push_back (p); // re-append
-
// C++11 version.
//
std::unique_ptr<string> p (new string ("hello"));
@@ -3296,6 +3291,13 @@ f (object& o)
p = s.detach_back (); // detach and pop
s.push_back (std::move (p)); // re-append
+ // C++98 version.
+ //
+ std::auto_ptr<string> p (new string ("hello"));
+ s.push_back (p); // assumes ownership
+ p = s.detach_back (); // detach and pop
+ s.push_back (p); // re-append
+
// Setting a new container.
//
object::member_sequence n;
@@ -3617,7 +3619,9 @@ w[0].amount (10000);
For the complete working code shown in this section refer to the
order/element
example in the
- examples/cxx/tree/
directory in the XSD distribution.
cxx/tree/
directory in the
+ xsd-examples
+ package.
If both the base and derived types are ordered, then the content order sequence is only added to the base and the content @@ -3646,8 +3650,7 @@ w[0].amount (10000);
As an example, here is how we can use the Boost Multi-Index
container for content order. First we create the
content-order-container.hxx
header with the
- following definition (in C++11, use the alias template
- instead):
#ifndef CONTENT_ORDER_CONTAINER @@ -3665,7 +3668,7 @@ struct by_id {}; struct by_id_index {}; template <typename T> -struct content_order_container: +using content_order_container = boost::multi_index::multi_index_container< T, boost::multi_index::indexed_by< @@ -3679,8 +3682,7 @@ struct content_order_container: boost::multi_index::member<T, std::size_t, &T::id> > > - > -{}; + >; #endif@@ -3734,7 +3736,7 @@ for (id_iterator i (r.first); i != r.second; ++i)
The parsing functions read XML instance documents and return
corresponding object models as an automatic pointer
- (std::auto_ptr
or std::unique_ptr
,
+ (std::unique_ptr
or std::auto_ptr
,
depending on the C++ standard selected). Their signatures
have the following pattern (type
denotes
element's type and name
denotes element's
@@ -3742,7 +3744,7 @@ for (id_iterator i (r.first); i != r.second; ++i)
-std::[auto|unique]_ptr<type> +std::[unique|auto]_ptr<type> name (....);@@ -3814,13 +3816,13 @@ public: value (const value_type&); void - value (std::[auto|unique]_ptr<value_type>); + value (std::[unique|auto]_ptr<value_type>); // Constructors. // root (const value_type&); - root (std::[auto|unique]_ptr<value_type>); + root (std::[unique|auto]_ptr<value_type>); root (const xercesc::DOMElement&, xml_schema::flags = 0); @@ -3916,7 +3918,7 @@ namespace xml_schema class element_map { public: - static std::[auto|unique]_ptr<xml_schema::element_type> + static std::[unique|auto]_ptr<xml_schema::element_type> parse (const xercesc::DOMElement&, flags = 0); static void @@ -3927,8 +3929,8 @@ namespace xml_schema
The parse()
function creates the corresponding
element type object based on the element name and namespace
- and returns it as an automatic pointer (std::auto_ptr
- or std::unique_ptr
, depending on the C++ standard
+ and returns it as an automatic pointer (std::unique_ptr
+ or std::auto_ptr
, depending on the C++ standard
selected) to xml_schema::element_type
.
The serialize()
function serializes the passed element
object to DOMElement
. Note that in case of
@@ -3965,7 +3967,7 @@ struct no_element_info: virtual exception
//
DOMElement& e = ... // Parse XML to DOM.
-auto_ptr<xml_schema::element_type> r (
+unique_ptr<xml_schema::element_type> r (
xml_schema::element_map::parse (e));
if (root1 r1 = dynamic_cast<root1*> (r.get ()))
@@ -4097,7 +4099,7 @@ f (root& r)
i != r.item ().end ()
++i)
{
- std::auto_ptr<base> c (i->_clone ());
+ std::unique_ptr<base> c (i->_clone ());
}
}
@@ -4881,8 +4883,9 @@ for (batch::content_order_const_iterator i (b.content_order ().begin ());
For the complete working code that shows the use of wildcards in
ordered types refer to the order/element
example in
- the examples/cxx/tree/
directory in the XSD
- distribution.
cxx/tree/
directory in the
+ xsd-examples
+ package.
anyAttribute
For the complete working code that shows the use of mixed content
in ordered types refer to the order/mixed
example in
- the examples/cxx/tree/
directory in the XSD
- distribution.
cxx/tree/
directory in the
+ xsd-examples
+ package.
@@ -5318,18 +5322,18 @@ for (text::content_order_const_iterator i (t.content_order ().begin ());
// Read from a URI or a local file.
//
-std::[auto|unique]_ptr<type>
+std::[unique|auto]_ptr<type>
name (const std::basic_string<C>& uri,
xml_schema::flags = 0,
const xml_schema::properties& = xml_schema::properties ());
-std::[auto|unique]_ptr<type>
+std::[unique|auto]_ptr<type>
name (const std::basic_string<C>& uri,
xml_schema::error_handler&,
xml_schema::flags = 0,
const xml_schema::properties& = xml_schema::properties ());
-std::[auto|unique]_ptr<type>
+std::[unique|auto]_ptr<type>
name (const std::basic_string<C>& uri,
xercesc::DOMErrorHandler&,
xml_schema::flags = 0,
@@ -5339,38 +5343,38 @@ name (const std::basic_string<C>& uri,
// Read from std::istream.
//
-std::[auto|unique]_ptr<type>
+std::[unique|auto]_ptr<type>
name (std::istream&,
xml_schema::flags = 0,
const xml_schema::properties& = xml_schema::properties ());
-std::[auto|unique]_ptr<type>
+std::[unique|auto]_ptr<type>
name (std::istream&,
xml_schema::error_handler&,
xml_schema::flags = 0,
const xml_schema::properties& = xml_schema::properties ());
-std::[auto|unique]_ptr<type>
+std::[unique|auto]_ptr<type>
name (std::istream&,
xercesc::DOMErrorHandler&,
xml_schema::flags = 0,
const xml_schema::properties& = xml_schema::properties ());
-std::[auto|unique]_ptr<type>
+std::[unique|auto]_ptr<type>
name (std::istream&,
const std::basic_string<C>& id,
xml_schema::flags = 0,
const xml_schema::properties& = xml_schema::properties ());
-std::[auto|unique]_ptr<type>
+std::[unique|auto]_ptr<type>
name (std::istream&,
const std::basic_string<C>& id,
xml_schema::error_handler&,
xml_schema::flags = 0,
const xml_schema::properties& = xml_schema::properties ());
-std::[auto|unique]_ptr<type>
+std::[unique|auto]_ptr<type>
name (std::istream&,
const std::basic_string<C>& id,
xercesc::DOMErrorHandler&,
@@ -5381,18 +5385,18 @@ name (std::istream&,
// Read from InputSource.
//
-std::[auto|unique]_ptr<type>
+std::[unique|auto]_ptr<type>
name (xercesc::InputSource&,
xml_schema::flags = 0,
const xml_schema::properties& = xml_schema::properties ());
-std::[auto|unique]_ptr<type>
+std::[unique|auto]_ptr<type>
name (xercesc::InputSource&,
xml_schema::error_handler&,
xml_schema::flags = 0,
const xml_schema::properties& = xml_schema::properties ());
-std::[auto|unique]_ptr<type>
+std::[unique|auto]_ptr<type>
name (xercesc::InputSource&,
xercesc::DOMErrorHandler&,
xml_schema::flags = 0,
@@ -5402,13 +5406,13 @@ name (xercesc::InputSource&,
// Read from DOM.
//
-std::[auto|unique]_ptr<type>
+std::[unique|auto]_ptr<type>
name (const xercesc::DOMDocument&,
xml_schema::flags = 0,
const xml_schema::properties& = xml_schema::properties ());
-std::[auto|unique]_ptr<type>
-name (xml_schema::dom::[auto|unique]_ptr<xercesc::DOMDocument>,
+std::[unique|auto]_ptr<type>
+name (xml_schema::dom::[unique|auto]_ptr<xercesc::DOMDocument>,
xml_schema::flags = 0,
const xml_schema::properties& = xml_schema::properties ());
@@ -5418,7 +5422,7 @@ name (xml_schema::dom::[auto|unique]_ptr<xercesc::DOMDocument>,
or a pre-parsed DOM instance in the form of
xercesc::DOMDocument
. All the parsing functions
return a dynamically allocated object model as either
- std::auto_ptr
or std::unique_ptr
,
+ std::unique_ptr
or std::auto_ptr
,
depending on the C++ standard selected. Each of these parsing
functions is discussed in more detail in the following sections.
@@ -5462,7 +5466,7 @@ name (xml_schema::dom::[auto|unique]_ptr<xercesc::DOMDocument>,
keep_dom
flag in
the call to the parsing function with the
- xml_schema::dom::[auto|unique]_ptr<DOMDocument>
+ xml_schema::dom::[unique|auto]_ptr<DOMDocument>
argument.xml_schema::flags::dont_validate
using xml_schema::flags; -std::auto_ptr<type> r ( +std::unique_ptr<type> r ( name ("test.xml", flags::keep_dom | flags::dont_validate));@@ -5912,19 +5916,19 @@ struct no_prefix_mapping: virtual exception For example:
-using std::auto_ptr; +using std::unique_ptr; -auto_ptr<type> r1 (name ("test.xml")); -auto_ptr<type> r2 (name ("https://www.codesynthesis.com/test.xml")); +unique_ptr<type> r1 (name ("test.xml")); +unique_ptr<type> r2 (name ("https://www.codesynthesis.com/test.xml"));-
Or, in the C++11 mode:
+Or, in the C++98 mode:
-using std::unique_ptr; +using std::auto_ptr; -unique_ptr<type> r1 (name ("test.xml")); -unique_ptr<type> r2 (name ("https://www.codesynthesis.com/test.xml")); +auto_ptr<type> r1 (name ("test.xml")); +auto_ptr<type> r2 (name ("https://www.codesynthesis.com/test.xml"));
std::istream
-using std::auto_ptr; +using std::unique_ptr; { std::ifstream ifs ("test.xml"); - auto_ptr<type> r (name (ifs, "test.xml")); + unique_ptr<type> r (name (ifs, "test.xml")); } { std::string str ("..."); // Some XML fragment. std::istringstream iss (str); - auto_ptr<type> r (name (iss)); + unique_ptr<type> r (name (iss)); }@@ -5958,7 +5962,7 @@ using std::auto_ptr;
xercesc::StdInInputSource is; -std::auto_ptr<type> r (name (is)); +std::unique_ptr<type> r (name (is));
-// C++98 version. -// -xml_schema::dom::auto_ptr<xercesc::DOMDocument> doc = ... - -std::auto_ptr<type> r ( - name (doc, xml_schema::flags::keep_dom | xml_schema::flags::own_dom)); - -// At this point doc is reset to 0. - // C++11 version. // xml_schema::dom::unique_ptr<xercesc::DOMDocument> doc = ... @@ -5999,6 +5994,15 @@ std::unique_ptr<type> r ( xml_schema::flags::keep_dom | xml_schema::flags::own_dom)); // At this point doc is reset to 0. + +// C++98 version. +// +xml_schema::dom::auto_ptr<xercesc::DOMDocument> doc = ... + +std::auto_ptr<type> r ( + name (doc, xml_schema::flags::keep_dom | xml_schema::flags::own_dom)); + +// At this point doc is reset to 0.
-std::auto_ptr<type> r = ... +std::unique_ptr<type> r = ... std::ofstream ofs ("test.xml"); xml_schema::namespace_infomap map; name (ofs, @@ -6384,7 +6388,7 @@ struct serialization: virtual exception// Obtain the object model. // -std::auto_ptr<type> r = ... +std::unique_ptr<type> r = ... // Prepare namespace mapping and schema location information. // @@ -6417,11 +6421,11 @@ name (std::cout, *r, map);-using std::auto_ptr; +using std::unique_ptr; // Obtain the object model. // -auto_ptr<type> r = ... +unique_ptr<type> r = ... // Prepare namespace mapping and schema location information. // @@ -6437,15 +6441,15 @@ XMLPlatformUtils::Initialize (); { // Choose a target. // - auto_ptr<XMLFormatTarget> ft; + unique_ptr<XMLFormatTarget> ft; if (argc != 2) { - ft = auto_ptr<XMLFormatTarget> (new StdOutFormatTarget ()); + ft = unique_ptr<XMLFormatTarget> (new StdOutFormatTarget ()); } else { - ft = auto_ptr<XMLFormatTarget> ( + ft = unique_ptr<XMLFormatTarget> ( new LocalFileFormatTarget (argv[1])); } @@ -6477,7 +6481,7 @@ XMLPlatformUtils::Terminate ();// Obtain the object model. // -std::auto_ptr<type> r = ... +std::unique_ptr<type> r = ... using namespace xercesc; @@ -6565,7 +6569,7 @@ XMLPlatformUtils::Initialize (); { // Parse XML to object model. // - std::auto_ptr<type> r (root ( + std::unique_ptr<type> r (root ( "root.xml", xml_schema::flags::keep_dom | xml_schema::flags::dont_initialize)); @@ -6612,7 +6616,7 @@ XMLPlatformUtils::Initialize (); { // Parse XML to object model. // - std::auto_ptr<type> r (root ( + std::unique_ptr<type> r (root ( "root.xml", xml_schema::flags::keep_dom | xml_schema::flags::dont_initialize)); @@ -6703,7 +6707,7 @@ XMLPlatformUtils::Terminate ();// Parse XML to object model. // -std::auto_ptr<type> r (root ("root.xml")); +std::unique_ptr<type> r (root ("root.xml")); // Save to a CDR stream. // @@ -6717,7 +6721,7 @@ ocdr << *r; ACE_InputCDR ace_icdr (buf, size); xml_schema::istream<ACE_InputCDR> icdr (ace_icdr); -std::auto_ptr<object> copy (new object (icdr)); +std::unique_ptr<object> copy (new object (icdr)); // Serialize to XML. // -- cgit v1.1