summaryrefslogtreecommitdiff
path: root/xsd/cxx/tree
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2014-07-03 09:57:09 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2014-07-03 09:57:09 +0200
commit1a4099b78717b16f632b0e7e0980a27811221e52 (patch)
tree87a63393fc207082b7418987309581a9a79e49a4 /xsd/cxx/tree
parent06258b8eae3d5af9a1af0206bb5a8e5c80dde455 (diff)
Implement anyType and anySimpleType content representation
anyType as a DOM fragment, similar to wildcards. anySimpleType as a text string.
Diffstat (limited to 'xsd/cxx/tree')
-rw-r--r--xsd/cxx/tree/fundamental-header.hxx2
-rw-r--r--xsd/cxx/tree/options.cli7
-rw-r--r--xsd/cxx/tree/stream-extraction-source.cxx22
-rw-r--r--xsd/cxx/tree/tree-header.cxx16
-rw-r--r--xsd/cxx/tree/tree-inline.cxx22
-rw-r--r--xsd/cxx/tree/tree-source.cxx8
6 files changed, 65 insertions, 12 deletions
diff --git a/xsd/cxx/tree/fundamental-header.hxx b/xsd/cxx/tree/fundamental-header.hxx
index 1145c0c..925d65e 100644
--- a/xsd/cxx/tree/fundamental-header.hxx
+++ b/xsd/cxx/tree/fundamental-header.hxx
@@ -241,7 +241,7 @@ namespace CXX
traverse (SemanticGraph::AnySimpleType& t)
{
simple_type_ = built_in_type (
- t, L"::xsd::cxx::tree::simple_type< ", type_);
+ t, L"::xsd::cxx::tree::simple_type< " + char_type + L", ", type_);
if (doxygen)
os << "/**" << endl
diff --git a/xsd/cxx/tree/options.cli b/xsd/cxx/tree/options.cli
index 026e4a1..f1b343a 100644
--- a/xsd/cxx/tree/options.cli
+++ b/xsd/cxx/tree/options.cli
@@ -170,6 +170,13 @@ namespace CXX
this option."
};
+ bool --generate-any-type
+ {
+ "Extract and store content of the XML Schema \cb{anyType} type as a
+ DOM fragment. Note that you need to initialize the Xerces-C++ runtime
+ if you are using this option."
+ };
+
NarrowStrings --generate-insertion
{
"<os>",
diff --git a/xsd/cxx/tree/stream-extraction-source.cxx b/xsd/cxx/tree/stream-extraction-source.cxx
index a1ca4bc..ceb56c1 100644
--- a/xsd/cxx/tree/stream-extraction-source.cxx
+++ b/xsd/cxx/tree/stream-extraction-source.cxx
@@ -321,6 +321,7 @@ namespace CXX
SemanticGraph::Type& t (e.type ());
String type (etype (e));
+ String tr (etraits (e)); // traits type name
bool fund (false);
{
@@ -389,8 +390,8 @@ namespace CXX
}
else
{
- os << auto_ptr << "< " << type << " > r (new " << type <<
- " (s, f, this));";
+ os << auto_ptr << "< " << type << " > r (" << endl
+ << tr << "::create (s, f, this));";
}
os << "c.push_back (" << r << ");"
@@ -438,8 +439,8 @@ namespace CXX
}
else
{
- os << auto_ptr << "< " << type << " > r (new " << type <<
- " (s, f, this));";
+ os << auto_ptr << "< " << type << " > r (" << endl
+ << tr << "::create (s, f, this));";
}
os << "this->" << member << ".set (" << r << ");"
@@ -482,8 +483,8 @@ namespace CXX
}
else
{
- os << auto_ptr << "< " << type << " > r (new " << type <<
- " (s, f, this));";
+ os << auto_ptr << "< " << type << " > r (" << endl
+ << tr << "::create (s, f, this));";
}
os << "this->" << member << ".set (" << r << ");"
@@ -507,6 +508,7 @@ namespace CXX
{
String const& member (emember (a));
String type (etype (a));
+ String tr (etraits (a)); // traits type name
bool fund (false);
{
@@ -530,8 +532,8 @@ namespace CXX
}
else
{
- os << "this->" << member << ".set (" << auto_ptr << "< " <<
- type << " > (new " << type << " (s, f, this)));";
+ os << "this->" << member << ".set (" << tr <<
+ "::create (s, f, this));";
}
os << "}" // if (p)
@@ -549,8 +551,8 @@ namespace CXX
}
else
{
- os << "this->" << member << ".set (" << auto_ptr << "< " <<
- type << " > (new " << type << " (s, f, this)));";
+ os << "this->" << member << ".set (" << tr <<
+ "::create (s, f, this));";
}
os << "}";
diff --git a/xsd/cxx/tree/tree-header.cxx b/xsd/cxx/tree/tree-header.cxx
index e6c2411..f0c3560 100644
--- a/xsd/cxx/tree/tree-header.cxx
+++ b/xsd/cxx/tree/tree-header.cxx
@@ -291,6 +291,22 @@ namespace CXX
<< "~" << name << " ();";
os << "};";
+
+ // Comparison operators.
+ //
+ if (options.generate_comparison ())
+ {
+ os << inst_exp
+ << "bool" << endl
+ << "operator== (const " << name << "&, const " << name << "&);"
+ << endl;
+
+ os << inst_exp
+ << "bool" << endl
+ << "operator!= (const " << name << "&, const " << name << "&);"
+ << endl
+ << endl;
+ }
}
private:
diff --git a/xsd/cxx/tree/tree-inline.cxx b/xsd/cxx/tree/tree-inline.cxx
index e6ed756..500ee73 100644
--- a/xsd/cxx/tree/tree-inline.cxx
+++ b/xsd/cxx/tree/tree-inline.cxx
@@ -82,6 +82,28 @@ namespace CXX
<< " " << base_type << " (o, f, this)"
<< "{"
<< "}";
+
+ // Comparison operators.
+ //
+ if (options.generate_comparison ())
+ {
+ os << inl
+ << "bool" << endl
+ << "operator== (const " << name << "& x, " <<
+ "const " << name << "& y)"
+ << "{"
+ << "const " << base_type << "& bx (x);"
+ << "return bx == y;"
+ << "}";
+
+ os << inl
+ << "bool" << endl
+ << "operator!= (const " << name << "& x, " <<
+ "const " << name << "& y)"
+ << "{"
+ << "return !(x == y);"
+ << "}";
+ }
}
private:
diff --git a/xsd/cxx/tree/tree-source.cxx b/xsd/cxx/tree/tree-source.cxx
index 110cb25..9524463 100644
--- a/xsd/cxx/tree/tree-source.cxx
+++ b/xsd/cxx/tree/tree-source.cxx
@@ -756,7 +756,13 @@ namespace CXX
if (!fund)
{
os << auto_ptr << "< " << type << " > r (" << endl
- << tr << "::create (i, f, this));"
+ << tr << "::create (i, f";
+
+ if (t.is_a<SemanticGraph::AnyType> () &&
+ options.generate_any_type ())
+ os << " | " << flags_type << "::extract_content";
+
+ os << ", this));"
<< endl;
}
}