From 0fdf19714613a82a184f4f6e75fb9a4f9b62f18a Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 19 Jan 2014 10:05:08 +0200 Subject: Use std::unique_ptr instead of std::auto_ptr in C++11 mode --- doc/cxx/parser/guide/index.xhtml | 83 ++++++++++++++++++++++++---------------- 1 file changed, 50 insertions(+), 33 deletions(-) (limited to 'doc/cxx/parser') diff --git a/doc/cxx/parser/guide/index.xhtml b/doc/cxx/parser/guide/index.xhtml index a01b9a7..fff36cb 100644 --- a/doc/cxx/parser/guide/index.xhtml +++ b/doc/cxx/parser/guide/index.xhtml @@ -280,10 +280,11 @@ 5Mapping Configuration - - - - + + + + +
5.1Character Type and Encoding
5.2Underlying XML Parser
5.3XML Schema Validation
5.4Support for Polymorphism
5.1C++ Standard
5.2Character Type and Encoding
5.3Underlying XML Parser
5.4XML Schema Validation
5.5Support for Polymorphism
@@ -553,8 +554,8 @@ $ xsd cxx-parser --xml-parser expat hello.xsd

The --xml-parser option indicates that we want to - use Expat as the underlying XML parser (see Section - 5.2, "Underlying XML Parser"). The XSD compiler produces two + use Expat as the underlying XML parser (see Section + 5.3, "Underlying XML Parser"). The XSD compiler produces two C++ files: hello-pskel.hxx and hello-pskel.cxx. The following code fragment is taken from hello-pskel.hxx; it should give you an idea about what gets generated: @@ -1615,8 +1616,13 @@ namespace http://www.example.com/xmlns/my following map files. The string-based XML Schema types are mapped to either std::string or std::wstring depending on the character type - selected (see Section 5.1, "Character Type and - Encoding" for more information).

+ selected (see Section 5.2, "Character Type and + Encoding" for more information). The binary XML Schema + types are mapped to either std::auto_ptr<xml_schema::buffer> + or std::unique_ptr<xml_schema::buffer> + depending on the C++ standard selected (C++98 or C++11, + respectively; refer to the --std XSD compiler + command line option for details).

 namespace http://www.w3.org/2001/XMLSchema
@@ -1663,10 +1669,10 @@ namespace http://www.w3.org/2001/XMLSchema
 
   QName xml_schema::qname;
 
-  base64Binary std::auto_ptr<xml_schema::buffer>
-               std::auto_ptr<xml_schema::buffer>;
-  hexBinary std::auto_ptr<xml_schema::buffer>
-            std::auto_ptr<xml_schema::buffer>;
+  base64Binary std::[auto|unique]_ptr<xml_schema::buffer>
+               std::[auto|unique]_ptr<xml_schema::buffer>;
+  hexBinary std::[auto|unique]_ptr<xml_schema::buffer>
+            std::[auto|unique]_ptr<xml_schema::buffer>;
 
   date xml_schema::date;
   dateTime xml_schema::date_time;
@@ -1899,9 +1905,9 @@ age:    28
   

The C++/Parser mapping has a number of configuration parameters that determine the overall properties and behavior of the generated code. Configuration parameters are specified with the XSD command line - options and include the character type that is used by the generated - code, the underlying XML parser, whether the XML Schema validation - is performed in the generated code, and support for XML Schema + options and include the C++ standard, the character type that is used + by the generated code, the underlying XML parser, whether the XML Schema + validation is performed in the generated code, and support for XML Schema polymorphism. This chapter describes these configuration parameters in more detail. For more ways to configure the generated code refer to the @@ -1909,7 +1915,16 @@ age: 28 Compiler Command Line Manual.

-

5.1 Character Type and Encoding

+

5.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 + 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.

+ +

5.2 Character Type and Encoding

The C++/Parser mapping has built-in support for two character types: char and wchar_t. You can select the @@ -1940,7 +1955,7 @@ age: 28 all three (object mode, input XML, and output XML) can have different encodings.

-

5.2 Underlying XML Parser

+

5.3 Underlying XML Parser

The C++/Parser mapping can be used with either Xerces-C++ or Expat as the underlying XML parser. You can select the XML parser with @@ -1954,7 +1969,7 @@ age: 28 in Chapter 7, "Document Parser and Error Handling".

-

5.3 XML Schema Validation

+

5.4 XML Schema Validation

The C++/Parser mapping provides support for validating a commonly-used subset of W3C XML Schema in the generated code. @@ -1963,14 +1978,14 @@ age: 28

By default validation in the generated code is disabled if the underlying XML parser is validating (Xerces-C++) and - enabled otherwise (Expat). See Section 5.2, + enabled otherwise (Expat). See Section 5.3, "Underlying XML Parser" for more information about the underlying XML parser. You can override the default behavior with the --generate-validation and --suppress-validation command line options.

-

5.4 Support for Polymorphism

+

5.5 Support for Polymorphism

By default the XSD compiler generates non-polymorphic code. If your vocabulary uses XML Schema polymorphism in the form of xsi:type @@ -2587,14 +2602,14 @@ private: base64Binary base64_binary_pimpl - std::auto_ptr<xml_schema::buffer>
+ std::[auto|unique]_ptr< xml_schema::buffer>
Section 6.3, "base64Binary and hexBinary Parsers" hexBinary hex_binary_pimpl - std::auto_ptr<xml_schema::buffer>
+ std::[auto|unique]_ptr< xml_schema::buffer>
Section 6.3, "base64Binary and hexBinary Parsers" @@ -2738,10 +2753,12 @@ namespace xml_schema

6.3 base64Binary and hexBinary Parsers

The return type of the base64_binary_pimpl and - hex_binary_pimpl parser implementations is - std::auto_ptr<xml_schema::buffer>. The - xml_schema::buffer type represents a binary buffer - and its interface is presented below.

+ hex_binary_pimpl parser implementations is either + std::auto_ptr<xml_schema::buffer> (C++98) or + std::unique_ptr<xml_schema::buffer> (C++11), + depending on the C++ standard selected (--std XSD + compiler option). The xml_schema::buffer type + represents a binary buffer and its interface is presented below.

 namespace xml_schema
@@ -3304,7 +3321,7 @@ namespace xml_schema
      in more detail. As mentioned in Section 3.4,
      "Connecting the Parsers Together", the interface of
      xml_schema::document depends on the underlying XML
-     parser selected (Section 5.2, "Underlying XML
+     parser selected (Section 5.3, "Underlying XML
      Parser"). The following sections describe the
      document type interface for Xerces-C++ and
      Expat as underlying parsers.

@@ -3315,7 +3332,7 @@ namespace xml_schema document type has the following interface. Note that if the character type is wchar_t, then the string type in the interface becomes std::wstring - (see Section 5.1, "Character Type and Encoding").

+ (see Section 5.2, "Character Type and Encoding").

 namespace xml_schema
@@ -3577,7 +3594,7 @@ namespace xml_schema
      polymorphic, specifies whether the XML documents
      being parsed use polymorphism. For more information on support
      for XML Schema polymorphism in the C++/Parser mapping refer
-     to Section 5.4, "Support for Polymorphism".

+ to Section 5.5, "Support for Polymorphism".

The rest of the document interface consists of overloaded parse() functions. The last two arguments in each of these @@ -3610,7 +3627,7 @@ namespace xml_schema document type has the following interface. Note that if the character type is wchar_t, then the string type in the interface becomes std::wstring - (see Section 5.1, "Character Type and Encoding").

+ (see Section 5.2, "Character Type and Encoding").

 namespace xml_schema
@@ -3747,7 +3764,7 @@ namespace xml_schema
      polymorphic, specifies whether the XML documents
      being parsed use polymorphism. For more information on support
      for XML Schema polymorphism in the C++/Parser mapping refer
-     to Section 5.4, "Support for Polymorphism".

+ to Section 5.5, "Support for Polymorphism".

A number of overloaded parse() functions have the system_id and public_id arguments. The @@ -3895,7 +3912,7 @@ main (int argc, char* argv[]) character type is wchar_t, then the string type and output stream type in the definition become std::wstring and std::wostream, - respectively (see Section 5.1, "Character Type + respectively (see Section 5.2, "Character Type and Encoding").

@@ -4008,7 +4025,7 @@ main (int argc, char* argv[])
      listing presents the definition of the error_handler
      interface. Note that if the character type is wchar_t,
      then the string type in the interface becomes std::wstring
-     (see Section 5.1, "Character Type and Encoding").

+ (see Section 5.2, "Character Type and Encoding").

 namespace xml_schema
-- 
cgit v1.1