From f60df03e3cedb86508645357e17003eb9281f31a Mon Sep 17 00:00:00 2001
From: Boris Kolpackov In addition, if requested by specifying the This function detaches the value from the tree leaving the member
+ value uninitialized. Accessing such an uninitialized value prior to
+ re-initializing it results in undefined behavior. The following code shows how one could use this mapping:--generate-detach
+ option and only for members of non-fundamental C++ types, the mapping
+ provides a detach function that returns an automatic pointer to the
+ member's type, for example:
+class object: xml_schema::type
+{
+public:
+ ...
+
+ std::auto_ptr<member_type>
+ detach_member ();
+ ...
+
+};
+
+
+ std::vector
. One notable extension
- to the standard interface that is available only for
- sequences of non-fundamental C++ types is the addition of
+ as if it was std::vector
. Two notable extensions
+ to the standard interface that are available only for
+ sequences of non-fundamental C++ types are the addition of
the overloaded push_back
and insert
- member functions which instead of the constant reference
- to the element type accept automatic pointer to the element
- type. These functions assume ownership of the pointed to
- object and resets the passed automatic pointer.
-
detach_back
and detach
+ member functions. The additional push_back
and
+ insert
functions accept an automatic pointer to the
+ element type instead of the constant reference. They assume
+ ownership of the pointed to object and resets the passed
+ automatic pointer. The detach_back
and
+ detach
functions detach the element
+ value from the sequence container and, by default, remove
+ the element from the sequence. These additional functions
+ have the following signatures:
+
+ +template <typename X> +class sequence +{ +public: + ... + + void + push_back (std::auto_ptr<X>) + + iterator + insert (iterator position, std::auto_ptr<X>) + + std::auto_ptr<X> + detach_back (bool pop = true); + + iterator + detach (iterator position, + std::auto_ptr<X>& result, + bool erase = true) + + ... +} +
The following code shows how one could use this mapping:
@@ -3074,7 +3135,9 @@ f (object& o) s.push_back ("hello"); // deep copy std::auto_ptr<string> p (new string ("hello")); - s.push_back (o); // assumes ownership + s.push_back (p); // assumes ownership + p = s.detach_back (); // detach and pop + s.push_back (p); // re-append // Setting a new container. // diff --git a/documentation/xsd.1 b/documentation/xsd.1 index 762d865..7536bb6 100644 --- a/documentation/xsd.1 +++ b/documentation/xsd.1 @@ -800,6 +800,13 @@ not initialized and accessing them results in undefined behavior. Generate constructors that expect an instance of a base type followed by all required members. +.IP "\fB\--generate-detach\fR" +Generate detach functions for required elements and attributes (detach +functions for optional and sequence cardinalities are provided by the +respective containers). These functions, for example, allow you to move +sub-trees in the object model either within the same tree or between +different trees. + .IP "\fB\--generate-wildcard\fR" Generate accessors and modifiers as well as parsing and serialization code for XML Schema wildcards diff --git a/documentation/xsd.xhtml b/documentation/xsd.xhtml index 46e8c1a..1330509 100644 --- a/documentation/xsd.xhtml +++ b/documentation/xsd.xhtml @@ -711,6 +711,13 @@--generate-detach
--generate-wildcard
any
and
--
cgit v1.1