diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2010-10-18 11:17:51 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2010-10-18 11:17:51 +0200 |
commit | d80d096ee8743fd6f7382d274272b0b6d7faf9bf (patch) | |
tree | d0f0bee1e645cb2b86b6837ac0db8a7d2821e533 /libxsde/xsde/cxx/hybrid | |
parent | 0e4637025fa8d1b4234b0512561d31f0dd023843 (diff) |
Support for schema evolution using substitution groups
New examples: hybrid/evolution/ignore and hybrid/evolution/passthrough.
Diffstat (limited to 'libxsde/xsde/cxx/hybrid')
-rw-r--r-- | libxsde/xsde/cxx/hybrid/any-type-pskel.cxx | 44 | ||||
-rw-r--r-- | libxsde/xsde/cxx/hybrid/parser-map.cxx | 17 | ||||
-rw-r--r-- | libxsde/xsde/cxx/hybrid/serializer-map.cxx | 17 |
3 files changed, 50 insertions, 28 deletions
diff --git a/libxsde/xsde/cxx/hybrid/any-type-pskel.cxx b/libxsde/xsde/cxx/hybrid/any-type-pskel.cxx index d8434b2..bb5bb7f 100644 --- a/libxsde/xsde/cxx/hybrid/any-type-pskel.cxx +++ b/libxsde/xsde/cxx/hybrid/any-type-pskel.cxx @@ -13,15 +13,16 @@ namespace xsde { #ifdef XSDE_POLYMORPHIC bool any_type_pskel:: - _start_element_impl (const ro_string& ns, - const ro_string& name, - const char* type) + _start_element_impl ( +#ifdef XSDE_PARSER_VALIDATION + const ro_string& ns, const ro_string& name, const char* type +#else + const ro_string&, const ro_string&, const char* +#endif + ) { #ifdef XSDE_PARSER_VALIDATION - parser::context& ctx = _context (); - ctx.current_.any_ = true; - ctx.current_.depth_++; - + _context ().start_wildcard_content (); _start_any_element (ns, name, type); return true; #else @@ -30,13 +31,16 @@ namespace xsde } #else bool any_type_pskel:: - _start_element_impl (const ro_string& ns, const ro_string& name) + _start_element_impl ( +#ifdef XSDE_PARSER_VALIDATION + const ro_string& ns, const ro_string& name +#else + const ro_string&, const ro_string& +#endif + ) { #ifdef XSDE_PARSER_VALIDATION - parser::context& ctx = _context (); - ctx.current_.any_ = true; - ctx.current_.depth_++; - + _context ().start_wildcard_content (); _start_any_element (ns, name); return true; #else @@ -46,7 +50,13 @@ namespace xsde #endif bool any_type_pskel:: - _end_element_impl (const ro_string& ns, const ro_string& name) + _end_element_impl ( +#ifdef XSDE_PARSER_VALIDATION + const ro_string& ns, const ro_string& name +#else + const ro_string&, const ro_string& +#endif + ) { #ifdef XSDE_PARSER_VALIDATION _end_any_element (ns, name); @@ -76,7 +86,13 @@ namespace xsde #endif bool any_type_pskel:: - _characters_impl (const ro_string& s) + _characters_impl ( +#ifdef XSDE_PARSER_VALIDATION + const ro_string& s +#else + const ro_string& +#endif + ) { #ifdef XSDE_PARSER_VALIDATION _any_characters (s); diff --git a/libxsde/xsde/cxx/hybrid/parser-map.cxx b/libxsde/xsde/cxx/hybrid/parser-map.cxx index ae67b94..33b0a53 100644 --- a/libxsde/xsde/cxx/hybrid/parser-map.cxx +++ b/libxsde/xsde/cxx/hybrid/parser-map.cxx @@ -21,23 +21,26 @@ namespace xsde if (size_ == 0) return 0; + int r (1); + size_t m; size_t l = 0; size_t h = size_ - 1; while (l <= h) { - size_t m = l + (h - l)/2; - int r = strcmp (entries_[m].type_id, tid); + m = l + (h - l)/2; + r = strcmp (entries_[m].type_id, tid); - if (r > 0) - h = m - 1; - else if (r < 0) + if (r == 0 || l == h) + break; + + if (r < 0) l = m + 1; else - return entries_[m].parser; + h = (m == 0 ? 0 : m - 1); } - return 0; + return r == 0 ? entries_[m].parser : 0; } void parser_map_impl:: diff --git a/libxsde/xsde/cxx/hybrid/serializer-map.cxx b/libxsde/xsde/cxx/hybrid/serializer-map.cxx index d20f8d1..be32cc4 100644 --- a/libxsde/xsde/cxx/hybrid/serializer-map.cxx +++ b/libxsde/xsde/cxx/hybrid/serializer-map.cxx @@ -23,23 +23,26 @@ namespace xsde if (size_ == 0) return 0; + int r (1); + size_t m; size_t l = 0; size_t h = size_ - 1; while (l <= h) { - size_t m = l + (h - l)/2; - int r = strcmp (entries_[m].type_id, tid); + m = l + (h - l)/2; + r = strcmp (entries_[m].type_id, tid); - if (r > 0) - h = m - 1; - else if (r < 0) + if (r == 0 || l == h) + break; + + if (r < 0) l = m + 1; else - return entries_[m].serializer; + h = (m == 0 ? 0 : m - 1); } - return 0; + return r == 0 ? entries_[m].serializer : 0; } void serializer_map_impl:: |