From 0d62005a3ff3b62d02c2eb3fd8644e0e19b202e8 Mon Sep 17 00:00:00 2001
From: Boris Kolpackov It is also evident that the built-in XML Schema type
When C++ exceptions are disabled, the signatures of the
@@ -2029,34 +2032,37 @@ public:
change as follows: That is, the functions that may require memory allocation
@@ -2067,103 +2073,106 @@ public:
are implemented in terms of the following class template: Most of this interface is identical to the fixed-length type
@@ -2175,7 +2184,7 @@ public:
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. The When STL is enabled, the string sequence have the same
- interface as When STL is enabled, the string
is mapped to std::string
.
- The internal string_sequence
class that
- is used in the name_sequence
type definition
+ The string_sequence
class that is used in
+ the name_sequence
type definition
has an interface similar to std::vector
. The
mapping between the built-in XML Schema types and C++ types
is described in more detail in Chapter 5,
@@ -1599,7 +1599,7 @@ private:
public:
// person
//
- typedef xsde::fix_sequence<person> person_sequence;
+ typedef xml_schema::fix_sequence<person> person_sequence;
typedef person_sequence::iterator person_iterator;
typedef person_sequence::const_iterator person_const_iterator;
@@ -1891,7 +1891,7 @@ class people
{
// person
//
- typedef xsde::fix_sequence<person> person_sequence;
+ typedef xml_schema::fix_sequence<person> person_sequence;
typedef person_sequence::iterator person_iterator;
typedef person_sequence::const_iterator person_const_iterator;
@@ -1927,100 +1927,103 @@ class people
are implemented in terms of the following class template:
-template <typename T>
-class fix_sequence
+namespace xml_schema
{
-public:
- typedef T value_type;
- typedef T* pointer;
- typedef const T* const_pointer;
- typedef T& reference;
- typedef const T& const_reference;
+ template <typename T>
+ class fix_sequence
+ {
+ public:
+ typedef T value_type;
+ typedef T* pointer;
+ typedef const T* const_pointer;
+ typedef T& reference;
+ typedef const T& const_reference;
- typedef size_t size_type;
- typedef ptrdiff_t difference_type;
+ typedef size_t size_type;
+ typedef ptrdiff_t difference_type;
- typedef T* iterator;
- typedef const T* const_iterator;
+ typedef T* iterator;
+ typedef const T* const_iterator;
-public:
- fix_sequence ();
+ public:
+ fix_sequence ();
- void
- swap (fix_sequence&);
+ void
+ swap (fix_sequence&);
-private:
- fix_sequence (const fix_sequence&);
+ private:
+ fix_sequence (const fix_sequence&);
- fix_sequence&
- operator= (fix_sequence&);
+ fix_sequence&
+ operator= (fix_sequence&);
-public:
- iterator
- begin ();
+ public:
+ iterator
+ begin ();
- const_iterator
- begin () const;
+ const_iterator
+ begin () const;
- iterator
- end ();
+ iterator
+ end ();
- const_iterator
- end () const;
+ const_iterator
+ end () const;
- T&
- front ();
+ T&
+ front ();
- const T&
- front () const;
+ const T&
+ front () const;
- T&
- back ();
+ T&
+ back ();
- const T&
- back () const;
+ const T&
+ back () const;
- T&
- operator[] (size_t);
+ T&
+ operator[] (size_t);
- const T&
- operator[] (size_t) const;
+ const T&
+ operator[] (size_t) const;
-public:
- bool
- empty () const;
+ public:
+ bool
+ empty () const;
- size_t
- size () const;
+ size_t
+ size () const;
- size_t
- capacity () const;
+ size_t
+ capacity () const;
- size_t
- max_size () const;
+ size_t
+ max_size () const;
-public:
- void
- clear ();
+ public:
+ void
+ clear ();
- void
- pop_back ();
+ void
+ pop_back ();
- iterator
- erase (iterator);
+ iterator
+ erase (iterator);
- void
- push_back (const T&);
+ void
+ push_back (const T&);
- iterator
- insert (iterator, const T&);
+ iterator
+ insert (iterator, const T&);
- void
- reserve (size_t);
+ void
+ reserve (size_t);
- void
- assign (const T* src, size_t n);
-};
+ void
+ assign (const T* src, size_t n);
+ };
+}
-template <typename T>
-class fix_sequence
+namespace xml_schema
{
-public:
- enum error
+ template <typename T>
+ class fix_sequence
{
- error_none,
- error_no_memory
- };
+ public:
+ enum error
+ {
+ error_none,
+ error_no_memory
+ };
- ...
+ ...
-public:
- error
- push_back (const T&);
+ public:
+ error
+ push_back (const T&);
- error
- insert (iterator, const T&);
+ error
+ insert (iterator, const T&);
- error
- insert (iterator, const T&, iterator& result);
+ error
+ insert (iterator, const T&, iterator& result);
- error
- reserve (size_t);
+ error
+ reserve (size_t);
- error
- assign (const T* src, size_t n);
-};
+ error
+ assign (const T* src, size_t n);
+ };
+}
-template <typename T>
-class var_sequence
+namespace xml_schema
{
-public:
- typedef T value_type;
- typedef T* pointer;
- typedef const T* const_pointer;
- typedef T& reference;
- typedef const T& const_reference;
+ template <typename T>
+ class var_sequence
+ {
+ public:
+ typedef T value_type;
+ typedef T* pointer;
+ typedef const T* const_pointer;
+ typedef T& reference;
+ typedef const T& const_reference;
- typedef size_t size_type;
- typedef ptrdiff_t difference_type;
+ typedef size_t size_type;
+ typedef ptrdiff_t difference_type;
- typedef <implementation details> iterator;
- typedef <implementation details> const_iterator;
+ typedef <implementation details> iterator;
+ typedef <implementation details> const_iterator;
-public:
- var_sequence ();
+ public:
+ var_sequence ();
- void
- swap (var_sequence&);
+ void
+ swap (var_sequence&);
-private:
- var_sequence (const var_sequence&);
+ private:
+ var_sequence (const var_sequence&);
- var_sequence&
- operator= (var_sequence&);
+ var_sequence&
+ operator= (var_sequence&);
-public:
- iterator
- begin ();
+ public:
+ iterator
+ begin ();
- const_iterator
- begin () const;
+ const_iterator
+ begin () const;
- iterator
- end ();
+ iterator
+ end ();
- const_iterator
- end () const;
+ const_iterator
+ end () const;
- T&
- front ();
+ T&
+ front ();
- const T&
- front () const;
+ const T&
+ front () const;
- T&
- back ();
+ T&
+ back ();
- const T&
- back () const;
+ const T&
+ back () const;
- T&
- operator[] (size_t);
+ T&
+ operator[] (size_t);
- const T&
- operator[] (size_t) const;
+ const T&
+ operator[] (size_t) const;
-public:
- bool
- empty () const;
+ public:
+ bool
+ empty () const;
- size_t
- size () const;
+ size_t
+ size () const;
- size_t
- capacity () const;
+ size_t
+ capacity () const;
- size_t
- max_size () const;
+ size_t
+ max_size () const;
-public:
- void
- clear ();
+ public:
+ void
+ clear ();
- void
- push_back (T*);
+ void
+ push_back (T*);
- iterator
- insert (iterator, T*);
+ iterator
+ insert (iterator, T*);
- void
- pop_back ();
+ void
+ pop_back ();
- iterator
- erase (iterator);
+ iterator
+ erase (iterator);
- void
- reserve (size_t);
+ void
+ reserve (size_t);
- T*
- detach (iterator);
+ T*
+ detach (iterator);
- void
- attach (iterator, T*);
-};
+ void
+ attach (iterator, T*);
+ };
+}
var_sequence
- interface also provides the detach()
and attach()
+ class template 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
.
@@ -2187,39 +2196,42 @@ public:
return an error code to signal the out of memory condition:
-template <typename T>
-class var_sequence
+namespace xml_schema
{
-public:
- enum error
+ template <typename T>
+ class var_sequence
{
- error_none,
- error_no_memory
- };
+ public:
+ enum error
+ {
+ error_none,
+ error_no_memory
+ };
- ...
+ ...
-public:
- error
- push_back (T*);
+ public:
+ error
+ push_back (T*);
- error
- insert (iterator, T*);
+ error
+ insert (iterator, T*);
- error
- insert (iterator, T*, iterator& result);
+ error
+ insert (iterator, T*, iterator& result);
- error
- reserve (size_t);
-};
+ error
+ reserve (size_t);
+ };
+}
- fix_sequence<std::string>
. When
+ string_sequence
class has
+ the same interface as fix_sequence<std::string>
. When
STL is disabled and strings are mapped to char*
,
- the string sequence has a special interface. When C++ exceptions are
- enabled, it has the following definition:string_sequence
has a special interface. When C++
+ exceptions are enabled, it has the following definition:
namespace xml_schema @@ -2333,7 +2345,7 @@ namespace xml_schema free the passed string if the reallocation of the underlying sequence buffer fails. Thepush_back_copy()
function makes a copy of the passed string. - Thestring_sequence
interface also provides the + Thestring_sequence
class also provides thedetach()
andattach()
functions. Thedetach()
function allows you to detach the contained string at the specified position. A detached string @@ -2454,7 +2466,7 @@ public: // b // - typedef xsde::string_sequence b_sequence; + typedef xml_schema::string_sequence b_sequence; typedef b_sequence::iterator b_iterator; typedef b_sequence::const_iterator b_const_iterator; @@ -2518,7 +2530,7 @@ public: ... }; - typedef xsde::fix_sequence<sequence1_type> sequence1_sequence; + typedef xml_schema::fix_sequence<sequence1_type> sequence1_sequence; typedef sequence1_sequence::iterator sequence1_iterator; typedef sequence1_sequence::const_iterator sequence1_const_iterator; @@ -2782,7 +2794,7 @@ public: ... }; - typedef xsde::fix_sequence<choice_type> choice_sequence; + typedef xml_schema::fix_sequence<choice_type> choice_sequence; typedef choice_sequence::iterator choice_iterator; typedef choice_sequence::const_iterator choice_const_iterator; @@ -3158,7 +3170,7 @@ public: // Custom data. // - typedef xsde::data_sequence custom_data_sequence; + typedef xml_schema::data_sequence custom_data_sequence; typedef custom_data_sequence::iterator custom_data_iterator; typedef custom_data_sequence::const_iterator custom_data_const_iterator; @@ -3175,101 +3187,104 @@ public: custom data sequence has the following interface:-class data_sequence +namespace xml_schema { -public: - typedef void* value_type; - typedef void** pointer; - typedef const void** const_pointer; - typedef void* reference; - typedef const void* const_reference; + class data_sequence + { + public: + typedef void* value_type; + typedef void** pointer; + typedef const void** const_pointer; + typedef void* reference; + typedef const void* const_reference; - typedef size_t size_type; - typedef ptrdiff_t difference_type; + typedef size_t size_type; + typedef ptrdiff_t difference_type; - typedef void** iterator; - typedef const void* const* const_iterator; + typedef void** iterator; + typedef const void* const* const_iterator; - typedef void (*destroy_func) (void* data, size_t pos); + typedef void (*destroy_func) (void* data, size_t pos); -public: - data_sequence (); + public: + data_sequence (); - void - destructor (destroy_func); + void + destructor (destroy_func); - void - swap (data_sequence&); + void + swap (data_sequence&); -private: - data_sequence (const data_sequence&); + private: + data_sequence (const data_sequence&); - data_sequence& - operator= (data_sequence&); + data_sequence& + operator= (data_sequence&); -public: - iterator - begin (); + public: + iterator + begin (); - const_iterator - begin () const; + const_iterator + begin () const; - iterator - end (); + iterator + end (); - const_iterator - end () const; + const_iterator + end () const; - void* - front (); + void* + front (); - const void* - front () const; + const void* + front () const; - void* - back (); + void* + back (); - const void* - back () const; + const void* + back () const; - void* - operator[] (size_t); + void* + operator[] (size_t); - const void* - operator[] (size_t) const; + const void* + operator[] (size_t) const; -public: - bool - empty () const; + public: + bool + empty () const; - size_t - size () const; + size_t + size () const; - size_t - capacity () const; + size_t + capacity () const; - size_t - max_size () const; + size_t + max_size () const; -public: - void - clear (); + public: + void + clear (); - void - pop_back (); + void + pop_back (); - iterator - erase (iterator); + iterator + erase (iterator); - void - push_back (void*); + void + push_back (void*); - iterator - insert (iterator, void*); + iterator + insert (iterator, void*); - void - reserve (size_t); -}; + void + reserve (size_t); + }; +}The
destructor()
modifier allows you to specify @@ -3286,30 +3301,33 @@ public: return an error code to signal the out of memory condition:-class data_sequence +namespace xml_schema { -public: - enum error + class data_sequence { - error_none, - error_no_memory - }; + public: + enum error + { + error_none, + error_no_memory + }; - ... + ... -public: - error - push_back (void*); + public: + error + push_back (void*); - error - insert (iterator, void*); + error + insert (iterator, void*); - error - insert (iterator, void*, iterator& result); + error + insert (iterator, void*, iterator& result); - error - reserve (size_t); -}; + error + reserve (size_t); + }; +}The following code fragment shows how we can store and retrieve @@ -3453,7 +3471,7 @@ class people // person // - typedef xsde::fix_sequence<person> person_sequence; + typedef xml_schema::fix_sequence<person> person_sequence; typedef person_sequence::iterator person_iterator; typedef person_sequence::const_iterator person_const_iterator; -- cgit v1.1