From c319d785aef76c4e05859b81f956e446eb5a674d Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 18 Oct 2010 15:48:59 +0200 Subject: Use numerical value instead of symbolic enumerator name The enumerator names might not have been assigned. --- xsde/cxx/hybrid/default-value.cxx | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'xsde/cxx') diff --git a/xsde/cxx/hybrid/default-value.cxx b/xsde/cxx/hybrid/default-value.cxx index 712f405..abcc211 100644 --- a/xsde/cxx/hybrid/default-value.cxx +++ b/xsde/cxx/hybrid/default-value.cxx @@ -203,14 +203,31 @@ namespace CXX Enumeration& x (base_enum ? *base_enum : e); - os << member_ << x.context ().get ("value") << "("; + os << member_ << x.context ().get ("value") << "(" << endl; Enumeration::NamesIteratorPair ip (x.find (value_)); if (ip.first != ip.second) { - Enumerator& er (dynamic_cast (ip.first->named ())); - os << fq_name (e) << "::" << ename (er); + // Use the numerical value instead of the symbolic enumerator + // because the enumerator names might not have been assigned + // (included/imported schemas). + // + String const& vt (e.context ().get ("value-type")); + + Size n (0); + { + Enumeration const& tmp (x); + for (Enumeration::NamesConstIterator i (tmp.names_begin ()); + &i->named () != &ip.first->named (); ++i) + n++; + } + + os << "static_cast< " << fq_name (e) << "::" << vt << " > (" << + n << "UL)"; + + //Enumerator& er (dynamic_cast (ip.first->named ())); + //os << fq_name (e) << "::" << ename (er); } os << ");"; -- cgit v1.1