aboutsummaryrefslogtreecommitdiff
path: root/xsd/cxx/tree/stream-extraction-source.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2010-05-21 17:27:15 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2010-05-21 17:27:15 +0200
commitefb2476d01b2bcc62569c8748327754a836195c3 (patch)
treebbd26150d29bbef3b60ea6fa5ab8748b691161de /xsd/cxx/tree/stream-extraction-source.cxx
parentcc06299343476f6bda799cb55c060601543b7cf4 (diff)
Optimize enum representation in binary streams
For string-based enums use integer representation instead of string when storing in binary streams.
Diffstat (limited to 'xsd/cxx/tree/stream-extraction-source.cxx')
-rw-r--r--xsd/cxx/tree/stream-extraction-source.cxx28
1 files changed, 26 insertions, 2 deletions
diff --git a/xsd/cxx/tree/stream-extraction-source.cxx b/xsd/cxx/tree/stream-extraction-source.cxx
index 0828c79..3fe1bf0 100644
--- a/xsd/cxx/tree/stream-extraction-source.cxx
+++ b/xsd/cxx/tree/stream-extraction-source.cxx
@@ -175,6 +175,20 @@ namespace CXX
t.dispatch (e);
}
+ Boolean enum_based (false);
+ if (string_based)
+ {
+ SemanticGraph::Enumeration* base_enum (0);
+ IsEnumBasedType t (base_enum);
+ t.dispatch (e);
+
+ enum_based = (base_enum != 0);
+ }
+
+ String value;
+ if (string_based)
+ value = evalue (e);
+
UnsignedLong n (0);
Streams const& st (options.value<CLI::generate_extraction> ());
for (Streams::ConstIterator i (st.begin ()); i != st.end (); ++i)
@@ -188,8 +202,18 @@ namespace CXX
inherits (e, inherits_base_);
- os << " (s, f, c)"
- << "{";
+ if (string_based && !enum_based)
+ {
+ // Use copy c-tor to pass the flags and container.
+ //
+ os << " (" << endl;
+ inherits (e, inherits_base_);
+ os << " (_xsd_" << name << "_literals_[s.read_uint ()]), f, c)";
+ }
+ else
+ os << " (s, f, c)";
+
+ os << "{";
if (string_based)
os << "_xsd_" << name << "_convert ();";