aboutsummaryrefslogtreecommitdiff
path: root/xsde/cxx/hybrid/insertion-source.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'xsde/cxx/hybrid/insertion-source.cxx')
-rw-r--r--xsde/cxx/hybrid/insertion-source.cxx47
1 files changed, 47 insertions, 0 deletions
diff --git a/xsde/cxx/hybrid/insertion-source.cxx b/xsde/cxx/hybrid/insertion-source.cxx
index 7dc6fcb..7fce9ee 100644
--- a/xsde/cxx/hybrid/insertion-source.cxx
+++ b/xsde/cxx/hybrid/insertion-source.cxx
@@ -14,6 +14,51 @@ namespace CXX
{
namespace
{
+ struct Enumeration : Traversal::Enumeration, Context
+ {
+ Enumeration (Context& c, Traversal::Complex& complex)
+ : Context (c), complex_ (complex)
+ {
+ }
+
+ virtual Void
+ traverse (Type& e)
+ {
+ // First see if we should delegate this one to the Complex
+ // generator.
+ //
+ if (!enum_ || !enum_mapping (e))
+ {
+ complex_.traverse (e);
+ return;
+ }
+
+ String const& name (ename_custom (e));
+
+ // We may not need to generate the class if this type is
+ // being customized.
+ //
+ if (!name)
+ return;
+
+ for (Streams::ConstIterator i (ostreams.begin ());
+ i != ostreams.end (); ++i)
+ {
+ os << (exceptions ? "void" : "bool") << endl
+ << "operator<< (" << ostream (*i) << "& s," << endl
+ << "const " << name << "& x)"
+ << "{"
+ << "unsigned int i = x;"
+ << (exceptions ? "" : "return ") << "s << i;"
+ << "}"
+ << endl;
+ }
+ }
+
+ private:
+ Traversal::Complex& complex_;
+ };
+
struct List : Traversal::List, Context
{
List (Context& c)
@@ -721,6 +766,7 @@ namespace CXX
List list (ctx);
Union union_ (ctx);
Complex complex (ctx);
+ Enumeration enumeration (ctx, complex);
schema >> sources >> schema;
schema >> names_ns >> ns >> names;
@@ -728,6 +774,7 @@ namespace CXX
names >> list;
names >> union_;
names >> complex;
+ names >> enumeration;
schema.dispatch (ctx.schema_root);
}