aboutsummaryrefslogtreecommitdiff
path: root/xsd/cxx/tree/stream-insertion-source.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'xsd/cxx/tree/stream-insertion-source.cxx')
-rw-r--r--xsd/cxx/tree/stream-insertion-source.cxx30
1 files changed, 29 insertions, 1 deletions
diff --git a/xsd/cxx/tree/stream-insertion-source.cxx b/xsd/cxx/tree/stream-insertion-source.cxx
index f2e47a8..007e32c 100644
--- a/xsd/cxx/tree/stream-insertion-source.cxx
+++ b/xsd/cxx/tree/stream-insertion-source.cxx
@@ -398,6 +398,8 @@ namespace CXX
virtual void
traverse (Type& c)
{
+ SemanticGraph::Context& ctx (c.context ());
+
String name (ename (c));
// If renamed name is empty then we do not need to generate
@@ -406,7 +408,10 @@ namespace CXX
if (renamed_type (c, name) && !name)
return;
- bool has_body (has<Traversal::Member> (c) || c.inherits_p ());
+ bool ordered (ordered_p (c) && !ctx.count ("order-in-base"));
+ bool has_body (ordered ||
+ has<Traversal::Member> (c) ||
+ c.inherits_p ());
size_t n (0);
NarrowStrings const& st (options.generate_insertion ());
@@ -429,6 +434,29 @@ namespace CXX
os << "& > (x);";
}
+ // Write the order sequence.
+ //
+ if (ordered)
+ {
+ String const& ci (ctx.get<String> ("order-const-iterator"));
+ String const& an (ctx.get<String> ("order-aname"));
+
+ os << "s << ::xsd::cxx::tree::ostream_common::as_size< " <<
+ "::std::size_t > (" << endl
+ << "x." << an << " ().size ());"
+ << endl
+ << "for (" << name << "::" << ci << endl
+ << "b (x." << an << " ().begin ()), n (x." << an <<
+ " ().end ());" << endl
+ << "b != n; ++b)"
+ << "{"
+ << "s << ::xsd::cxx::tree::ostream_common::as_size< " <<
+ "::std::size_t > (b->id);"
+ << "s << ::xsd::cxx::tree::ostream_common::as_size< " <<
+ "::std::size_t > (b->index);"
+ << "}";
+ }
+
{
Traversal::Names names_member;
Element element (*this, name, *i);