From 4f38adc11ab1a3a1ab2dd3f958c917182be7d71f Mon Sep 17 00:00:00 2001
From: Boris Kolpackov new
and will eventually delete it
- 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
+ with operator delete
.
If you wish to make copies of variable-length objects, then
+ you can request the generation of the object cloning functions
+ with the --generate-clone
compiler
+ option. When this option is specified, each variable-length
+ type implements the _clone()
function which returns
+ a dynamically-allocated copy of the object or NULL
+ if the allocation failed and C++ exceptions are disabled (see
+ Section 3.3, "C++ Exceptions").
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:
@@ -2039,8 +2050,9 @@ private: </xs:complexType>-
If we compile it with XSD/e and specify the --generate-detach
- option, we will get the following C++ class:
If we compile it with XSD/e and specify the
+ --generate-clone
and --generate-detach
+ options, we will get the following C++ class:
// staff (variable-length)
@@ -2050,6 +2062,9 @@ class staff
public:
staff ();
+ staff*
+ _clone () const;
+
private:
staff (const staff&);
staff& operator= (const staff&);
@@ -4143,7 +4158,9 @@ for (people::person_iterator i = ps.begin (); i != ps.end (); ++i)
type is always variable-length which means objects of polymorphic
types are allocated dynamically and are stored and passed around
as pointers or references. A polymorphic type also defines a
- virtual destructor which allows you to delete an instance of a
+ virtual _clone()
function (see Section 4.2,
+ "Memory Management") and a virtual destructor
+ which allow you to copy and delete an instance of a
polymorphic type via a pointer to its base. The following code
fragment shows how we can parse, access, modify, and serialize
the above XML document:
@@ -4957,11 +4974,15 @@ namespace xml_schema
public:
void
+ assign (void* data, size_t size);
+
+ void
attach (void* data, size_t size, size_t capacity);
void*
detach ();
+
void
swap (buffer&);
@@ -5048,6 +5069,9 @@ namespace xml_schema
public:
error
+ assign (void* data, size_t size);
+
+ error
attach (void* data, size_t size, size_t capacity);
void*
diff --git a/documentation/xsde.1 b/documentation/xsde.1
index a4b55dc..4257882 100644
--- a/documentation/xsde.1
+++ b/documentation/xsde.1
@@ -1006,6 +1006,10 @@ documents.
.IP "\fB\--suppress-enum\fR"
Suppress the generation of the XML Schema enumeration to C++ enum mapping.
+.IP "\fB\--generate-clone\fR"
+Generate clone functions for variable-length types. These functions allow
+you to make dynamically-allocated copies of variable-length objects.
+
.IP "\fB\--generate-detach\fR"
Generate detach functions for elements and attributes of variable-length
types. These functions, for example, allow you to move sub-trees in the
diff --git a/documentation/xsde.xhtml b/documentation/xsde.xhtml
index 859719e..9797ba9 100644
--- a/documentation/xsde.xhtml
+++ b/documentation/xsde.xhtml
@@ -870,6 +870,11 @@
--generate-clone
--generate-detach