From 9a764d4ed5606c5f171ae05a7409128a88184b11 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 21 May 2010 19:18:52 +0200 Subject: Pool polymorphic type-id strings in binary representations Add support for an implicit string pool in istream and ostream templates. Use this support to pool type namespace and name when dealing with polymorphic types. --- libxsd/xsd/cxx/tree/stream-insertion-map.txx | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'libxsd/xsd/cxx/tree/stream-insertion-map.txx') diff --git a/libxsd/xsd/cxx/tree/stream-insertion-map.txx b/libxsd/xsd/cxx/tree/stream-insertion-map.txx index 07bfa8b..d5799c2 100644 --- a/libxsd/xsd/cxx/tree/stream-insertion-map.txx +++ b/libxsd/xsd/cxx/tree/stream-insertion-map.txx @@ -269,7 +269,24 @@ namespace xsd { const qualified_name& qn (ti->name ()); - s << qn.namespace_ () << qn.name (); + // Pool the namespace and name strings. + // + const std::basic_string& ns (qn.namespace_ ()); + const std::basic_string& n (qn.name ()); + + std::size_t ns_id (s.pool_string (ns)); + std::size_t n_id (s.pool_string (n)); + + s << ostream_common::as_size (ns_id); + + if (ns_id == 0) + s << ns; + + s << ostream_common::as_size (n_id); + + if (n_id == 0) + s << n; + ti->inserter () (s, x); } else -- cgit v1.1