From 4d3692a500bd5cf2bd500e1eb0632850ca8260ab Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 2 Jun 2011 04:27:02 +0200 Subject: Do not store flags in containers --- libxsd/xsd/cxx/tree/containers.hxx | 78 +++++++++++++++++-------------- libxsd/xsd/cxx/tree/containers.txx | 42 ++++++++--------- libxsd/xsd/cxx/tree/list.hxx | 20 ++++---- libxsd/xsd/cxx/tree/parsing.txx | 34 ++++++++------ libxsd/xsd/cxx/tree/stream-extraction.hxx | 6 +-- libxsd/xsd/cxx/tree/types.hxx | 6 +-- 6 files changed, 101 insertions(+), 85 deletions(-) (limited to 'libxsd/xsd/cxx/tree') diff --git a/libxsd/xsd/cxx/tree/containers.hxx b/libxsd/xsd/cxx/tree/containers.hxx index 29f1388..b460dd8 100644 --- a/libxsd/xsd/cxx/tree/containers.hxx +++ b/libxsd/xsd/cxx/tree/containers.hxx @@ -132,11 +132,11 @@ namespace xsd public: ~one (); - one (flags, container*); + one (container*); - one (const T&, flags, container*); + one (const T&, container*); - one (std::auto_ptr, flags, container*); + one (std::auto_ptr, container*); one (const one&, flags, container*); @@ -157,7 +157,10 @@ namespace xsd } void - set (const T&); + set (const T& x) + { + set (x, 0); + } void set (std::auto_ptr); @@ -178,8 +181,11 @@ namespace xsd } protected: + void + set (const T&, flags); + + protected: T* x_; - flags flags_; container* container_; }; @@ -188,12 +194,12 @@ namespace xsd class one { public: - one (flags, container*) + one (container*) : present_ (false) { } - one (const T& x, flags, container*) + one (const T& x, container*) : x_ (x), present_ (true) { } @@ -259,13 +265,13 @@ namespace xsd ~optional (); explicit - optional (flags = 0, container* = 0); + optional (container* = 0); explicit - optional (const T&, flags = 0, container* = 0); + optional (const T&, container* = 0); explicit - optional (std::auto_ptr, flags = 0, container* = 0); + optional (std::auto_ptr, container* = 0); optional (const optional&, flags = 0, container* = 0); @@ -332,7 +338,10 @@ namespace xsd } void - set (const T&); + set (const T& x) + { + set (x, 0); + } void set (std::auto_ptr); @@ -349,13 +358,15 @@ namespace xsd return std::auto_ptr (x); } - private: + protected: + void + set (const T&, flags); + void true_ (); - private: + protected: T* x_; - flags flags_; container* container_; }; @@ -367,13 +378,13 @@ namespace xsd { public: explicit - optional (flags = 0, container* = 0) + optional (container* = 0) : present_ (false) { } explicit - optional (const T&, flags = 0, container* = 0); + optional (const T&, container* = 0); optional (const optional&, flags = 0, container* = 0); @@ -859,33 +870,33 @@ namespace xsd typedef base_sequence::allocator_type allocator_type; protected: - sequence_common (flags f, container* c) - : flags_ (f), container_ (c) + sequence_common (container* c) + : container_ (c) { } sequence_common (size_type n, const type& x, container* c) - : flags_ (0), container_ (c) + : container_ (c) { assign (n, x); } template sequence_common (const I& begin, const I& end, container* c) - : flags_ (0), container_ (c) + : container_ (c) { assign (begin, end); } sequence_common (const sequence_common& v, flags f, container* c) - : flags_ (f), container_ (c) + : container_ (c) { v_.reserve (v.v_.size ()); for (base_const_iterator i (v.v_.begin ()), e (v.v_.end ()); i != e; ++i) { - ptr p ((**i)._clone (flags_, container_)); + ptr p ((**i)._clone (f, container_)); v_.push_back (p); } } @@ -906,7 +917,7 @@ namespace xsd { // We have no ptr_ref. // - ptr p ((**si)._clone (flags_, container_)); + ptr p ((**si)._clone (0, container_)); *di = p; } @@ -958,7 +969,7 @@ namespace xsd for (base_iterator i (v_.begin ()), e (v_.end ()); i != e; ++i) { - ptr p (x._clone (flags_, container_)); + ptr p (x._clone (0, container_)); *i = p; } } @@ -974,7 +985,7 @@ namespace xsd for (I i (begin); i != end; ++i) { - ptr p (i->_clone (flags_, container_)); + ptr p (i->_clone (0, container_)); v_.push_back (p); } } @@ -990,7 +1001,7 @@ namespace xsd for (base_iterator i (v_.begin () + old), e (v_.end ()); i != e; ++i) { - ptr p (x._clone (flags_, container_)); + ptr p (x._clone (0, container_)); *i = p; } } @@ -1004,7 +1015,7 @@ namespace xsd for (base_iterator i (v_.end () - d); n != 0; --n) { - ptr r (x._clone (flags_, container_)); + ptr r (x._clone (0, container_)); *(--i) = r; } } @@ -1021,7 +1032,7 @@ namespace xsd for (I i (end);;) { --i; - ptr r (i->_clone (flags_, container_)); + ptr r (i->_clone (0, container_)); p = v_.insert (p, r); if (i == begin) @@ -1031,7 +1042,6 @@ namespace xsd } protected: - flags flags_; container* container_; base_sequence v_; }; @@ -1075,8 +1085,8 @@ namespace xsd public: explicit - sequence (flags f = 0, container* c = 0) - : sequence_common (f, c) + sequence (container* c = 0) + : sequence_common (c) { } @@ -1260,7 +1270,7 @@ namespace xsd void push_back (const T& x) { - v_.push_back (ptr (x._clone (flags_, container_))); + v_.push_back (ptr (x._clone (0, container_))); } void @@ -1296,7 +1306,7 @@ namespace xsd { return iterator ( v_.insert ( - position.base (), ptr (x._clone (flags_, container_)))); + position.base (), ptr (x._clone (0, container_)))); } iterator @@ -1368,7 +1378,7 @@ namespace xsd public: explicit - sequence (flags = 0, container* = 0) + sequence (container* = 0) { } diff --git a/libxsd/xsd/cxx/tree/containers.txx b/libxsd/xsd/cxx/tree/containers.txx index 8c40e94..a27af48 100644 --- a/libxsd/xsd/cxx/tree/containers.txx +++ b/libxsd/xsd/cxx/tree/containers.txx @@ -23,23 +23,23 @@ namespace xsd template one:: - one (flags f, container* c) - : x_ (0), flags_ (f), container_ (c) + one (container* c) + : x_ (0), container_ (c) { } template one:: - one (const T& x, flags f, container* c) - : x_ (0), flags_ (f), container_ (c) + one (const T& x, container* c) + : x_ (0), container_ (c) { set (x); } template one:: - one (std::auto_ptr x, flags f, container* c) - : x_ (0), flags_ (f), container_ (c) + one (std::auto_ptr x, container* c) + : x_ (0), container_ (c) { set (x); } @@ -47,10 +47,10 @@ namespace xsd template one:: one (const one& x, flags f, container* c) - : x_ (0), flags_ (f), container_ (c) + : x_ (0), container_ (c) { if (x.present ()) - set (x.get ()); + set (x.get (), f); } template @@ -73,12 +73,12 @@ namespace xsd template void one:: - set (const T& x) + set (const T& x, flags f) { // We always do a fresh copy because T may not be x's // dynamic type. // - T* r (x._clone (flags_, container_)); + T* r (x._clone (f, container_)); delete x_; x_ = r; @@ -113,23 +113,23 @@ namespace xsd template optional:: - optional (flags f, container* c) - : x_ (0), flags_ (f), container_ (c) + optional (container* c) + : x_ (0), container_ (c) { } template optional:: - optional (const T& x, flags f, container* c) - : x_ (0), flags_ (f), container_ (c) + optional (const T& x, container* c) + : x_ (0), container_ (c) { set (x); } template optional:: - optional (std::auto_ptr x, flags f, container* c) - : x_ (0), flags_ (f), container_ (c) + optional (std::auto_ptr x, container* c) + : x_ (0), container_ (c) { set (x); } @@ -137,10 +137,10 @@ namespace xsd template optional:: optional (const optional& x, flags f, container* c) - : x_ (0), flags_ (f), container_ (c) + : x_ (0), container_ (c) { if (x) - set (*x); + set (*x, f); } template @@ -172,12 +172,12 @@ namespace xsd template void optional:: - set (const T& x) + set (const T& x, flags f) { // We always do a fresh copy because T may not be x's // dynamic type. // - T* r (x._clone (flags_, container_)); + T* r (x._clone (f, container_)); delete x_; x_ = r; @@ -220,7 +220,7 @@ namespace xsd // template optional:: - optional (const T& y, flags, container*) + optional (const T& y, container*) : present_ (false) { set (y); diff --git a/libxsd/xsd/cxx/tree/list.hxx b/libxsd/xsd/cxx/tree/list.hxx index 30416e6..0a455cf 100644 --- a/libxsd/xsd/cxx/tree/list.hxx +++ b/libxsd/xsd/cxx/tree/list.hxx @@ -39,8 +39,8 @@ namespace xsd { public: explicit - list (flags f = 0, container* c = 0) - : sequence (f, c) + list (container* c = 0) + : sequence (c) { } @@ -60,8 +60,8 @@ namespace xsd template list (istream&, flags = 0, container* c = 0); - list (const list& v, flags f = 0, container* c = 0) - : sequence (v, f, c) + list (const list& l, flags f = 0, container* c = 0) + : sequence (l, f, c) { } @@ -77,7 +77,9 @@ namespace xsd private: void - init (const std::basic_string&, const xercesc::DOMElement*); + init (const std::basic_string&, + const xercesc::DOMElement*, + flags); }; @@ -88,8 +90,8 @@ namespace xsd { public: explicit - list (flags f = 0, container* c = 0) - : sequence (f, c) + list (container* c = 0) + : sequence (c) { } @@ -108,8 +110,8 @@ namespace xsd template list (istream&, flags = 0, container* c = 0); - list (const list& s, flags f = 0, container* c = 0) - : sequence (s, f, c) + list (const list& l, flags f = 0, container* c = 0) + : sequence (l, f, c) { } diff --git a/libxsd/xsd/cxx/tree/parsing.txx b/libxsd/xsd/cxx/tree/parsing.txx index 929bf9f..bdeb539 100644 --- a/libxsd/xsd/cxx/tree/parsing.txx +++ b/libxsd/xsd/cxx/tree/parsing.txx @@ -176,17 +176,19 @@ namespace xsd template list:: list (const xercesc::DOMElement& e, flags f, container* c) - : sequence (flags (f & ~flags::keep_dom), c) // ambiguous + : sequence (c) { - init (text_content (e), &e); + init (text_content (e), &e, f & ~flags::keep_dom); } template list:: list (const xercesc::DOMAttr& a, flags f, container* c) - : sequence (flags (f & ~flags::keep_dom), c) // ambiguous + : sequence (c) { - init (xml::transcode (a.getValue ()), a.getOwnerElement ()); + init (xml::transcode (a.getValue ()), + a.getOwnerElement (), + f & ~flags::keep_dom); } template @@ -195,14 +197,16 @@ namespace xsd const xercesc::DOMElement* e, flags f, container* c) - : sequence (flags (f & ~flags::keep_dom), c) // ambiguous + : sequence (c) { - init (s, e); + init (s, e, f & ~flags::keep_dom); } template void list:: - init (const std::basic_string& s, const xercesc::DOMElement* parent) + init (const std::basic_string& s, + const xercesc::DOMElement* parent, + flags f) { if (s.size () == 0) return; @@ -226,7 +230,7 @@ namespace xsd ptr r ( new T (basic_string (data + i, j - i), parent, - this->flags_, + f, this->container_)); this->v_.push_back (r); @@ -240,7 +244,7 @@ namespace xsd ptr r ( new T (basic_string (data + i, size - i), parent, - this->flags_, + f, this->container_)); this->v_.push_back (r); @@ -252,16 +256,16 @@ namespace xsd template list:: - list (const xercesc::DOMElement& e, flags f, container* c) - : sequence (flags (f & ~flags::keep_dom), c) // ambiguous + list (const xercesc::DOMElement& e, flags, container* c) + : sequence (c) { init (text_content (e), &e); } template inline list:: - list (const xercesc::DOMAttr& a, flags f, container* c) - : sequence (flags (f & ~flags::keep_dom), c) // ambiguous + list (const xercesc::DOMAttr& a, flags, container* c) + : sequence (c) { init (xml::transcode (a.getValue ()), a.getOwnerElement ()); } @@ -270,9 +274,9 @@ namespace xsd inline list:: list (const std::basic_string& s, const xercesc::DOMElement* parent, - flags f, + flags, container* c) - : sequence (flags (f & ~flags::keep_dom), c) // ambiguous + : sequence (c) { init (s, parent); } diff --git a/libxsd/xsd/cxx/tree/stream-extraction.hxx b/libxsd/xsd/cxx/tree/stream-extraction.hxx index d5367c8..e8f1368 100644 --- a/libxsd/xsd/cxx/tree/stream-extraction.hxx +++ b/libxsd/xsd/cxx/tree/stream-extraction.hxx @@ -55,7 +55,7 @@ namespace xsd template list:: list (istream& s, flags f, container* c) - : sequence (f, c) + : sequence (c) { std::size_t size; istream_common::as_size as_size (size); @@ -76,8 +76,8 @@ namespace xsd template template list:: - list (istream& s, flags f, container* c) - : sequence (f, c) + list (istream& s, flags, container* c) + : sequence (c) { std::size_t size; istream_common::as_size as_size (size); diff --git a/libxsd/xsd/cxx/tree/types.hxx b/libxsd/xsd/cxx/tree/types.hxx index 3fbac75..5afa49d 100644 --- a/libxsd/xsd/cxx/tree/types.hxx +++ b/libxsd/xsd/cxx/tree/types.hxx @@ -1014,7 +1014,7 @@ namespace xsd * @brief Default constructor creates no elements. */ nmtokens () - : base_type (0, this) + : base_type (this) { } @@ -2483,7 +2483,7 @@ namespace xsd * @brief Default constructor creates no elements. */ idrefs () - : base_type (0, this) + : base_type (this) { } @@ -3677,7 +3677,7 @@ namespace xsd * @brief Default constructor creates no elements. */ entities () - : base_type (0, this) + : base_type (this) { } -- cgit v1.1