diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2010-01-08 17:03:18 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2010-01-08 17:03:18 +0200 |
commit | d0743458695eb2bb764bc308a9496db30f74f17a (patch) | |
tree | 27d33348bb9299b8460c0cebda9a8ed9031cdadd /xsd/cxx/tree/tree-source.cxx | |
parent | e6d52ecfa2379b1f7f3007e65ded5e4076abc5e9 (diff) |
Add support for binary (base64 and hex) default/fixed values
Diffstat (limited to 'xsd/cxx/tree/tree-source.cxx')
-rw-r--r-- | xsd/cxx/tree/tree-source.cxx | 70 |
1 files changed, 50 insertions, 20 deletions
diff --git a/xsd/cxx/tree/tree-source.cxx b/xsd/cxx/tree/tree-source.cxx index 4a94520..8c70f23 100644 --- a/xsd/cxx/tree/tree-source.cxx +++ b/xsd/cxx/tree/tree-source.cxx @@ -578,38 +578,68 @@ namespace CXX if (!lit) { - Boolean simple_init (true); + InitKind::Kind kind (InitKind::simple); { - IsSimpleInit test (simple_init); + InitKind test (kind); test.dispatch (t); } String const& member (edefault_value_member (m)); - String init_func; - if (!simple_init) - { - init_func = escape (L"_xsd_" + scope_ + member + L"_init"); - - os << "static " << scope_ << "::" << etype (m) << endl - << init_func << " ()" - << "{" - << scope_ << "::" << etype (m) << " r;" - << endl; - - init_value_.dispatch (t, m.value ()); + String init_name; - os << "return r;" - << "};"; + switch (kind) + { + case InitKind::data: + { + init_name = escape (L"_xsd_" + scope_ + member + L"data"); + init_value_.data (init_name); + init_value_.dispatch (t, m.value ()); + break; + } + case InitKind::function: + { + init_name = escape (L"_xsd_" + scope_ + member + L"init"); + + os << "static " << scope_ << "::" << etype (m) << endl + << init_name << " ()" + << "{" + << scope_ << "::" << etype (m) << " r;" + << endl; + + init_value_.dispatch (t, m.value ()); + + os << "return r;" + << "};"; + break; + } + case InitKind::simple: + break; } os << "const " << scope_ << "::" << etype (m) << " " << scope_ << "::" << member << " (" << endl; - if (simple_init) - init_value_.dispatch (t, m.value ()); - else - os << init_func << " ()"; + switch (kind) + { + case InitKind::data: + { + // Second dispatch. + // + init_value_.dispatch (t, m.value ()); + break; + } + case InitKind::function: + { + os << init_name << " ()"; + break; + } + case InitKind::simple: + { + init_value_.dispatch (t, m.value ()); + break; + } + } os << ");" << endl; |