From 0bfda486167432a9da8eec62b4578a22592a9275 Mon Sep 17 00:00:00 2001
From: Boris Kolpackov new
and will eventually delete it
- with operator delete
. As an example, let us extend
+ with operator delete
. You can also request generation
+ of detach functions with the --generate-detach
compiler
+ option. These functions allow you to detach a variable-length
+ object from the object model. As an example, let us extend
our people.xsd
schema with the following type:
@@ -1724,8 +1727,8 @@ private: </xs:complexType>-
If we compile it with XSD/e, we will get the following C++ - class:
+If we compile it with XSD/e and specify the --generate-detach
+ option, we will get the following C++ class:
// staff (variable-length) @@ -1751,6 +1754,9 @@ public: void permanent (people*); + people* + permanent_detach (); + // contract // const people& @@ -1762,6 +1768,9 @@ public: void contract (people*); + people* + contract_detach (); + private: ... }; @@ -2135,31 +2144,43 @@ public: clear (); void - pop_back (); + push_back (T*); iterator - erase (iterator); + insert (iterator, T*); void - push_back (T*); + pop_back (); iterator - insert (iterator, T*); + erase (iterator); - error + void reserve (size_t); + + T* + detach (iterator); + + void + attach (iterator, T*); };
Most of this interface is identical to the fixed-length type
- version except for the push_back()
and
+ version except for the push_back()
, and
insert()
functions. Similar to the modifier
functions for elements and attributes of variable-length
types, these two functions expect a pointer to the
dynamically-allocated instance of the type and assume
ownership of the passed object. To simplify error handling,
these two functions delete the passed object if the reallocation
- of the underlying sequence buffer fails.
var_sequence
+ interface also provides the detach()
and attach()
+ functions. The detach()
function allows you to detach
+ the contained object at the specified position. A detached object
+ should eventually be deallocated with operator delete
.
+ Similarly, the attach()
function allows you to attach
+ a new object at the specified position.
When C++ exceptions are disabled, the push_back()
,
insert()
, and reserve()
functions
@@ -2295,12 +2316,11 @@ namespace xml_schema
void
reserve (size_t);
- // Detach a string from the sequence at a given position.
- // The string pointer at this position in the sequence is
- // set to 0.
- //
char*
detach (iterator);
+
+ void
+ attach (iterator, char*);
};
}
@@ -2313,8 +2333,13 @@ namespace xml_schema
free the passed string if the reallocation of the underlying
sequence buffer fails. The push_back_copy()
function makes a copy of the passed string.
- If you detach the underlying element string, then it should
- eventually be deallocated with operator delete[]
.
string_sequence
interface also provides the
+ detach()
and attach()
functions.
+ The detach()
function allows you to detach
+ the contained string at the specified position. A detached string
+ should eventually be deallocated with operator delete[]
.
+ Similarly, the attach()
function allows you to attach
+ a new string at the specified position.
When C++ exceptions are disabled, the signatures of the
push_back()
, push_back_copy()
,
@@ -3714,6 +3739,9 @@ namespace xml_schema
void
base_value (char* x);
+ char*
+ base_value_detach ();
+
operator const char* () const;
operator char* ();
};
@@ -3722,7 +3750,9 @@ namespace xml_schema
Note that the string_base
object assumes ownership
of the strings passed to the assignment operator and the
- base_value()
modifier.
base_value()
modifier. If you detach the
+ string value then it should eventually be deallocated with
+ operator delete[]
.
QName
--suppress-serializer-val
--generate-detach
--generate-insertion os
os
output stream type. Repeat this
--
cgit v1.1