aboutsummaryrefslogtreecommitdiff
path: root/xsde/cxx/hybrid/tree-header.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2009-03-26 17:09:53 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2009-03-26 17:09:53 +0200
commite4c22d3686da0e973e21eae0561c1169c0eeff36 (patch)
tree0a49e9167edc88938b0287949080931314e8afea /xsde/cxx/hybrid/tree-header.cxx
parent0d62005a3ff3b62d02c2eb3fd8644e0e19b202e8 (diff)
Implement support for XML Schema polymorphism in C++/Hybrid
examples/cxx/hybrid/polyroot/ examples/cxx/hybrid/polymorphism/: new examples tests/cxx/hybrid/polymorphism/: new tests
Diffstat (limited to 'xsde/cxx/hybrid/tree-header.cxx')
-rw-r--r--xsde/cxx/hybrid/tree-header.cxx94
1 files changed, 79 insertions, 15 deletions
diff --git a/xsde/cxx/hybrid/tree-header.cxx b/xsde/cxx/hybrid/tree-header.cxx
index c2e8bf4..3003e4c 100644
--- a/xsde/cxx/hybrid/tree-header.cxx
+++ b/xsde/cxx/hybrid/tree-header.cxx
@@ -32,6 +32,9 @@ namespace CXX
//
if (name)
{
+ Boolean cd (lc.count ("cd-name"));
+ Boolean poly (polymorphic (l));
+
os << "// " << comment (l.name ()) << " (variable-length)" << endl
<< "//" << endl;
@@ -50,17 +53,23 @@ namespace CXX
os << "public:" << endl
<< name << " ();";
+ // d-tor
+ //
+ if (poly)
+ os << "virtual ~" << name << " ();";
+
+ os << endl;
+
// Custom data.
//
- if (lc.count ("cd-name"))
+ if (cd)
{
String const& name (ecd_name (l));
String const& sequence (ecd_sequence (l));
String const& iterator (ecd_iterator (l));
String const& const_iterator (ecd_const_iterator (l));
- os << endl
- << "// Custom data." << endl
+ os << "// Custom data." << endl
<< "//" << endl;
// sequence & iterators
@@ -84,9 +93,28 @@ namespace CXX
os << sequence << "&" << endl
<< name << " ();"
<< endl;
+ }
+
+ if (poly && typeinfo)
+ {
+ os << "// Type information." << endl
+ << "//" << endl;
+ os << "static const " <<
+ (stl ? "::std::string&" : "char*") << endl
+ << "_static_type ();"
+ << endl;
+
+ os << "virtual const " <<
+ (stl ? "::std::string&" : "char*") << endl
+ << "_dynamic_type () const;"
+ << endl;
+ }
+
+ if (cd)
+ {
os << "private:" << endl
- << sequence << " " << ecd_member (l) << ";";
+ << ecd_sequence (l) << " " << ecd_member (l) << ";";
}
os << "};";
@@ -128,15 +156,18 @@ namespace CXX
//
if (name)
{
+ Boolean fl (fixed_length (u));
+ Boolean poly (polymorphic (u));
Boolean cd (uc.count ("cd-name"));
- os << "// " << comment (u.name ()) << " (variable-length)" << endl
+ os << "// " << comment (u.name ()) << " (" <<
+ (fl ? "fixed-length" : "variable-length") << ")" << endl
<< "//" << endl;
os << "class " << name
<< "{";
- if (!fixed_length (u))
+ if (!fl)
os << "private:" << endl
<< name << " (const " << name << "&);"
<< name << "& operator= (const " << name << "&);"
@@ -148,13 +179,18 @@ namespace CXX
//
os << name << " ();";
+ // d-tor
+ //
+ if (!stl || poly)
+ os << (poly ? "virtual " : "") << "~" << name << " ();";
+
+ os << endl;
+
String const& value (uc.get<String> ("value"));
String const& member (uc.get<String> ("value-member"));
if (stl)
{
- os << endl;
-
// const std::string&
// name () const
//
@@ -178,11 +214,6 @@ namespace CXX
}
else
{
- // d-tor
- //
- os << "~" << name << " ();"
- << endl;
-
// const char*
// name () const
//
@@ -250,6 +281,22 @@ namespace CXX
<< endl;
}
+ if (poly && typeinfo)
+ {
+ os << "// Type information." << endl
+ << "//" << endl;
+
+ os << "static const " <<
+ (stl ? "::std::string&" : "char*") << endl
+ << "_static_type ();"
+ << endl;
+
+ os << "virtual const " <<
+ (stl ? "::std::string&" : "char*") << endl
+ << "_dynamic_type () const;"
+ << endl;
+ }
+
if (stl)
{
os << "private:" << endl
@@ -2337,6 +2384,7 @@ namespace CXX
if (name)
{
Boolean fl (fixed_length (c));
+ Boolean poly (polymorphic (c));
Boolean restriction (restriction_p (c));
Boolean cd (cc.count ("cd-name"));
@@ -2361,8 +2409,8 @@ namespace CXX
// d-tor
//
- if (!restriction)
- os << "~" << name << " ();";
+ if (!restriction || poly)
+ os << (poly ? "virtual " : "") << "~" << name << " ();";
// copy c-tor & operator=
//
@@ -2421,6 +2469,22 @@ namespace CXX
<< endl;
}
+ if (poly && typeinfo)
+ {
+ os << "// Type information." << endl
+ << "//" << endl;
+
+ os << "static const " <<
+ (stl ? "::std::string&" : "char*") << endl
+ << "_static_type ();"
+ << endl;
+
+ os << "virtual const " <<
+ (stl ? "::std::string&" : "char*") << endl
+ << "_dynamic_type () const;"
+ << endl;
+ }
+
if (!restriction || cd)
os << "private:" << endl;