summaryrefslogtreecommitdiff
path: root/xsd/xsd
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2014-07-23 15:21:29 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2014-07-23 15:21:29 +0200
commitbada6666c70977a058755ccf232e7d67b24adeed (patch)
tree1e92d50cebce96abaf9bce19e36026c47f77b9ba /xsd/xsd
parenteaf34adcbd8095bc6d1f3371b1227f654c7b19fc (diff)
New upstream release
Diffstat (limited to 'xsd/xsd')
-rw-r--r--xsd/xsd/cxx/elements.cxx237
-rw-r--r--xsd/xsd/cxx/elements.hxx208
-rw-r--r--xsd/xsd/cxx/literal-map.cxx80
-rw-r--r--xsd/xsd/cxx/literal-map.hxx13
-rw-r--r--xsd/xsd/cxx/option-types.cxx48
-rw-r--r--xsd/xsd/cxx/option-types.hxx35
-rw-r--r--xsd/xsd/cxx/options.cli551
-rw-r--r--xsd/xsd/cxx/options.cxx638
-rw-r--r--xsd/xsd/cxx/options.hxx440
-rw-r--r--xsd/xsd/cxx/options.ixx601
-rw-r--r--xsd/xsd/cxx/parser/attribute-validation-source.cxx45
-rw-r--r--xsd/xsd/cxx/parser/attribute-validation-source.hxx5
-rw-r--r--xsd/xsd/cxx/parser/characters-validation-source.cxx9
-rw-r--r--xsd/xsd/cxx/parser/characters-validation-source.hxx5
-rw-r--r--xsd/xsd/cxx/parser/cli.hxx154
-rw-r--r--xsd/xsd/cxx/parser/driver-source.cxx164
-rw-r--r--xsd/xsd/cxx/parser/driver-source.hxx5
-rw-r--r--xsd/xsd/cxx/parser/element-validation-source.cxx213
-rw-r--r--xsd/xsd/cxx/parser/element-validation-source.hxx5
-rw-r--r--xsd/xsd/cxx/parser/elements.cxx113
-rw-r--r--xsd/xsd/cxx/parser/elements.hxx74
-rw-r--r--xsd/xsd/cxx/parser/generator.cxx890
-rw-r--r--xsd/xsd/cxx/parser/generator.hxx28
-rw-r--r--xsd/xsd/cxx/parser/impl-header.cxx17
-rw-r--r--xsd/xsd/cxx/parser/impl-header.hxx5
-rw-r--r--xsd/xsd/cxx/parser/impl-source.cxx31
-rw-r--r--xsd/xsd/cxx/parser/impl-source.hxx5
-rw-r--r--xsd/xsd/cxx/parser/name-processor.cxx197
-rw-r--r--xsd/xsd/cxx/parser/name-processor.hxx15
-rw-r--r--xsd/xsd/cxx/parser/options.cli148
-rw-r--r--xsd/xsd/cxx/parser/options.cxx581
-rw-r--r--xsd/xsd/cxx/parser/options.hxx183
-rw-r--r--xsd/xsd/cxx/parser/options.ixx160
-rw-r--r--xsd/xsd/cxx/parser/parser-forward.cxx15
-rw-r--r--xsd/xsd/cxx/parser/parser-forward.hxx5
-rw-r--r--xsd/xsd/cxx/parser/parser-header.cxx175
-rw-r--r--xsd/xsd/cxx/parser/parser-header.hxx7
-rw-r--r--xsd/xsd/cxx/parser/parser-inline.cxx46
-rw-r--r--xsd/xsd/cxx/parser/parser-inline.hxx5
-rw-r--r--xsd/xsd/cxx/parser/parser-source.cxx139
-rw-r--r--xsd/xsd/cxx/parser/parser-source.hxx5
-rw-r--r--xsd/xsd/cxx/parser/print-impl-common.hxx89
-rw-r--r--xsd/xsd/cxx/parser/state-processor.cxx70
-rw-r--r--xsd/xsd/cxx/parser/state-processor.hxx10
-rw-r--r--xsd/xsd/cxx/parser/type-processor.cxx86
-rw-r--r--xsd/xsd/cxx/parser/type-processor.hxx19
-rw-r--r--xsd/xsd/cxx/parser/validator.cxx140
-rw-r--r--xsd/xsd/cxx/parser/validator.hxx20
-rw-r--r--xsd/xsd/cxx/tree/cli.hxx228
-rw-r--r--xsd/xsd/cxx/tree/counter.cxx64
-rw-r--r--xsd/xsd/cxx/tree/counter.hxx9
-rw-r--r--xsd/xsd/cxx/tree/default-value.cxx266
-rw-r--r--xsd/xsd/cxx/tree/default-value.hxx135
-rw-r--r--xsd/xsd/cxx/tree/elements.cxx428
-rw-r--r--xsd/xsd/cxx/tree/elements.hxx632
-rw-r--r--xsd/xsd/cxx/tree/fundamental-header.hxx160
-rw-r--r--xsd/xsd/cxx/tree/generator.cxx1470
-rw-r--r--xsd/xsd/cxx/tree/generator.hxx21
-rw-r--r--xsd/xsd/cxx/tree/name-processor.cxx622
-rw-r--r--xsd/xsd/cxx/tree/name-processor.hxx14
-rw-r--r--xsd/xsd/cxx/tree/options.cli480
-rw-r--r--xsd/xsd/cxx/tree/options.cxx1149
-rw-r--r--xsd/xsd/cxx/tree/options.hxx411
-rw-r--r--xsd/xsd/cxx/tree/options.ixx502
-rw-r--r--xsd/xsd/cxx/tree/order-processor.cxx244
-rw-r--r--xsd/xsd/cxx/tree/order-processor.hxx30
-rw-r--r--xsd/xsd/cxx/tree/parser-header.cxx39
-rw-r--r--xsd/xsd/cxx/tree/parser-header.hxx5
-rw-r--r--xsd/xsd/cxx/tree/parser-source.cxx151
-rw-r--r--xsd/xsd/cxx/tree/parser-source.hxx7
-rw-r--r--xsd/xsd/cxx/tree/polymorphism-processor.cxx216
-rw-r--r--xsd/xsd/cxx/tree/polymorphism-processor.hxx16
-rw-r--r--xsd/xsd/cxx/tree/serialization-header.cxx23
-rw-r--r--xsd/xsd/cxx/tree/serialization-header.hxx5
-rw-r--r--xsd/xsd/cxx/tree/serialization-source.cxx370
-rw-r--r--xsd/xsd/cxx/tree/serialization-source.hxx9
-rw-r--r--xsd/xsd/cxx/tree/stream-extraction-source.cxx231
-rw-r--r--xsd/xsd/cxx/tree/stream-extraction-source.hxx5
-rw-r--r--xsd/xsd/cxx/tree/stream-header.cxx19
-rw-r--r--xsd/xsd/cxx/tree/stream-header.hxx5
-rw-r--r--xsd/xsd/cxx/tree/stream-insertion-header.cxx37
-rw-r--r--xsd/xsd/cxx/tree/stream-insertion-header.hxx5
-rw-r--r--xsd/xsd/cxx/tree/stream-insertion-source.cxx173
-rw-r--r--xsd/xsd/cxx/tree/stream-insertion-source.hxx5
-rw-r--r--xsd/xsd/cxx/tree/stream-source.cxx89
-rw-r--r--xsd/xsd/cxx/tree/stream-source.hxx9
-rw-r--r--xsd/xsd/cxx/tree/tree-forward.cxx49
-rw-r--r--xsd/xsd/cxx/tree/tree-forward.hxx5
-rw-r--r--xsd/xsd/cxx/tree/tree-header.cxx689
-rw-r--r--xsd/xsd/cxx/tree/tree-header.hxx5
-rw-r--r--xsd/xsd/cxx/tree/tree-inline.cxx172
-rw-r--r--xsd/xsd/cxx/tree/tree-inline.hxx7
-rw-r--r--xsd/xsd/cxx/tree/tree-source.cxx1100
-rw-r--r--xsd/xsd/cxx/tree/tree-source.hxx7
-rw-r--r--xsd/xsd/cxx/tree/validator.cxx124
-rw-r--r--xsd/xsd/cxx/tree/validator.hxx11
-rw-r--r--xsd/xsd/elements.hxx30
-rw-r--r--xsd/xsd/makefile90
-rw-r--r--xsd/xsd/options-parser.hxx30
-rw-r--r--xsd/xsd/options.cli313
-rw-r--r--xsd/xsd/options.cxx976
-rw-r--r--xsd/xsd/options.hxx575
-rw-r--r--xsd/xsd/options.ixx462
-rw-r--r--xsd/xsd/processing/cardinality/processor.cxx105
-rw-r--r--xsd/xsd/processing/cardinality/processor.hxx11
-rw-r--r--xsd/xsd/processing/inheritance/processor.cxx95
-rw-r--r--xsd/xsd/processing/inheritance/processor.hxx11
-rw-r--r--xsd/xsd/type-map/lexer.cxx5
-rw-r--r--xsd/xsd/type-map/lexer.hxx19
-rw-r--r--xsd/xsd/type-map/parser.cxx21
-rw-r--r--xsd/xsd/type-map/parser.hxx16
-rw-r--r--xsd/xsd/type-map/type-map.hxx57
-rw-r--r--xsd/xsd/types.hxx20
-rw-r--r--xsd/xsd/usage.hxx226
-rw-r--r--xsd/xsd/xsd.cxx681
-rw-r--r--xsd/xsd/xsd.hxx81
116 files changed, 14455 insertions, 6556 deletions
diff --git a/xsd/xsd/cxx/elements.cxx b/xsd/xsd/cxx/elements.cxx
index d2600dc..dfa2f38 100644
--- a/xsd/xsd/cxx/elements.cxx
+++ b/xsd/xsd/cxx/elements.cxx
@@ -1,16 +1,14 @@
// file : xsd/cxx/elements.cxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#include <cxx/elements.hxx>
-#include <backend-elements/regex.hxx>
-
#include <cctype> // std::toupper
#include <memory>
#include <sstream>
#include <fstream>
+#include <cassert>
#include <iostream>
using std::wcerr;
@@ -28,7 +26,7 @@ namespace CXX
namespace
{
- WideChar const* keywords[] = {
+ wchar_t const* keywords[] = {
L"NULL",
L"and",
L"asm",
@@ -114,55 +112,47 @@ namespace CXX
Context (std::wostream& o,
SemanticGraph::Schema& root,
SemanticGraph::Path const& path,
- StringLiteralMap const* string_literal_map_,
- NarrowString const& char_type__,
- NarrowString const& char_encoding__,
- Boolean include_with_brackets__,
- NarrowString const& include_prefix__,
- NarrowString const& esymbol,
- Containers::Vector<NarrowString> const& nsm,
- Containers::Vector<NarrowString> const& nsr,
- Boolean trace_namespace_regex_,
- Containers::Vector<NarrowString> const& ir,
- Boolean trace_include_regex_,
- Boolean inline_,
- Containers::Vector<NarrowString> const& reserved_name)
+ options_type const& ops,
+ StringLiteralMap const* string_literal_map_)
: os (o),
schema_root (root),
schema_path (schema_path_),
+ options (ops),
+ std (ops.std ()),
char_type (char_type_),
char_encoding (char_encoding_),
L (L_),
string_type (string_type_),
+ auto_ptr (auto_ptr_),
string_literal_map (string_literal_map_),
- include_with_brackets (include_with_brackets_),
- include_prefix (include_prefix_),
type_exp (type_exp_),
inst_exp (inst_exp_),
inl (inl_),
ns_mapping_cache (ns_mapping_cache_),
schema_path_ (path),
xs_ns_ (0),
- char_type_ (char_type__),
- char_encoding_ (char_encoding__),
+ char_type_ (ops.char_type ()),
+ char_encoding_ (ops.char_encoding ()),
L_ (char_type == L"wchar_t" ? L"L" : L""),
- include_with_brackets_ (include_with_brackets__),
- include_prefix_ (include_prefix__),
- type_exp_ (esymbol ? esymbol + " " : esymbol),
- inst_exp_ (esymbol ? esymbol + "\n" : esymbol),
- inl_ (inline_ ? L"inline\n" : L""),
+ inl_ (ops.generate_inline () ? L"inline\n" : L""),
cxx_id_expr_ (L"^(::)?([a-zA-Z_]\\w*)(::[a-zA-Z_]\\w*)*$"),
cxx_id_expr (cxx_id_expr_),
- trace_namespace_regex (trace_namespace_regex_),
urn_mapping_ (L"#^urn.*:([a-zA-Z_].*)$#$1#"),
urn_mapping (urn_mapping_),
nsr_mapping (nsr_mapping_),
nsm_mapping (nsm_mapping_),
include_mapping (include_mapping_),
- trace_include_regex (trace_include_regex_),
reserved_name_map (reserved_name_map_),
keyword_set (keyword_set_)
{
+ // Export symbol.
+ //
+ {
+ String es (ops.export_symbol ());
+ type_exp_ = es ? es + L" " : es;
+ inst_exp_ = es ? es + L"\n" : es;
+ }
+
// Resolve and cache XML Schema namespace.
//
{
@@ -196,6 +186,12 @@ namespace CXX
else
string_type_ = L"::std::basic_string< " + char_type + L" >";
+ // Automatic pointer type.
+ //
+ auto_ptr_ = std >= cxx_version::cxx11
+ ? "::std::unique_ptr"
+ : "::std::auto_ptr";
+
// Default encoding.
//
if (!char_encoding)
@@ -209,28 +205,28 @@ namespace CXX
// Default mapping.
//
nsr_mapping_.push_back (
- Regex (L"#^.* (.*?/)??"L"(([a-zA-Z_]\\w*)(/[a-zA-Z_]\\w*)*)/?$#$2#"));
+ Regex (L"#^.* (.*?/)??" L"(([a-zA-Z_]\\w*)(/[a-zA-Z_]\\w*)*)/?$#$2#"));
nsr_mapping_.push_back (
Regex (L"#^.* http://www\\.w3\\.org/2001/XMLSchema$#xml_schema#"));
// Custom regex mapping.
//
- for (Containers::Vector<NarrowString>::ConstIterator
- i (nsr.begin ()), e (nsr.end ()); i != e; ++i)
+ for (NarrowStrings::const_iterator i (ops.namespace_regex ().begin ()),
+ e (ops.namespace_regex ().end ()); i != e; ++i)
{
- nsr_mapping_.push_back (Regex (*i));
+ nsr_mapping_.push_back (Regex (String (*i)));
}
// Custom direct mapping.
//
- for (Containers::Vector<NarrowString>::ConstIterator
- i (nsm.begin ()), e (nsm.end ()); i != e; ++i)
+ for (NarrowStrings::const_iterator i (ops.namespace_map ().begin ()),
+ e (ops.namespace_map ().end ()); i != e; ++i)
{
String s (*i);
// Split the string in two parts at the last '='.
//
- Size pos (s.rfind ('='));
+ size_t pos (s.rfind ('='));
if (pos == String::npos)
throw InvalidNamespaceMapping (s, "delimiter ('=') not found");
@@ -248,22 +244,22 @@ namespace CXX
// Include path regex
//
- for (Containers::Vector<NarrowString>::ConstIterator
- i (ir.begin ()), e (ir.end ()); i != e; ++i)
+ for (NarrowStrings::const_iterator i (ops.include_regex ().begin ()),
+ e (ops.include_regex ().end ()); i != e; ++i)
{
- include_mapping_.push_back (Regex (*i));
+ include_mapping_.push_back (Regex (String (*i)));
}
// Reserved names.
//
- for (Containers::Vector<NarrowString>::ConstIterator
- i (reserved_name.begin ()), e (reserved_name.end ()); i != e; ++i)
+ for (NarrowStrings::const_iterator i (ops.reserved_name ().begin ()),
+ e (ops.reserved_name ().end ()); i != e; ++i)
{
String s (*i);
// Split the string in two parts at '='.
//
- Size pos (s.find ('='));
+ size_t pos (s.find ('='));
if (pos == String::npos)
reserved_name_map_[s] = L"";
@@ -273,7 +269,7 @@ namespace CXX
// Populate the keyword set.
//
- for (Size i (0); i < sizeof (keywords) / sizeof (char*); ++i)
+ for (size_t i (0); i < sizeof (keywords) / sizeof (char*); ++i)
keyword_set_.insert (keywords[i]);
}
@@ -287,7 +283,7 @@ namespace CXX
using SemanticGraph::Sources;
String tmp;
- MapMapping::ConstIterator i (nsm_mapping.find (ns.name ()));
+ MapMapping::const_iterator i (nsm_mapping.find (ns.name ()));
if (i != nsm_mapping.end ())
{
@@ -317,20 +313,18 @@ namespace CXX
if (!path.empty ())
{
+ path.normalize ();
+
// Try to use the portable representation of the path. If that
// fails, fall back to the native representation.
//
try
{
- pair = path.string ();
+ pair = path.posix_string ();
}
catch (SemanticGraph::InvalidPath const&)
{
-#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2
- pair = path.native_file_string ();
-#else
pair = path.string ();
-#endif
}
}
@@ -338,7 +332,7 @@ namespace CXX
// Check cache first
//
- MappingCache::ConstIterator i (ns_mapping_cache.find (pair));
+ MappingCache::const_iterator i (ns_mapping_cache.find (pair));
if (i != ns_mapping_cache.end ())
{
@@ -346,32 +340,34 @@ namespace CXX
}
else
{
- if (trace_namespace_regex)
+ bool trace (options.namespace_regex_trace ());
+
+ if (trace)
wcerr << "namespace: '" << pair << "'" << endl;
- Boolean found (false);
+ bool found (false);
Regex colon (L"#/#::#");
- for (RegexMapping::ConstReverseIterator e (nsr_mapping.rbegin ());
+ for (RegexMapping::const_reverse_iterator e (nsr_mapping.rbegin ());
e != nsr_mapping.rend (); ++e)
{
- if (trace_namespace_regex)
- wcerr << "try: '" << e->pattern () << "' : ";
+ if (trace)
+ wcerr << "try: '" << e->regex () << "' : ";
if (e->match (pair))
{
- tmp = e->merge (pair);
- tmp = colon.merge (tmp); // replace `/' with `::'
+ tmp = e->replace (pair);
+ tmp = colon.replace (tmp); // replace `/' with `::'
// Check the result.
//
found = cxx_id_expr.match (tmp);
- if (trace_namespace_regex)
+ if (trace)
wcerr << "'" << tmp << "' : ";
}
- if (trace_namespace_regex)
+ if (trace)
wcerr << (found ? '+' : '-') << endl;
if (found)
@@ -392,7 +388,7 @@ namespace CXX
}
else
{
- tmp = colon.merge (n); // replace `/' with `::'
+ tmp = colon.replace (n); // replace `/' with `::'
if (!cxx_id_expr.match (tmp))
{
@@ -401,8 +397,8 @@ namespace CXX
if (urn_mapping.match (n))
{
Regex filter (L"#[.:-]#_#");
- tmp = urn_mapping.merge (n);
- tmp = filter.merge (tmp);
+ tmp = urn_mapping.replace (n);
+ tmp = filter.replace (tmp);
if (!cxx_id_expr.match (tmp))
throw NoNamespaceMapping (
@@ -496,7 +492,7 @@ namespace CXX
}
String Context::
- fq_name (SemanticGraph::Nameable& n, Char const* name_key)
+ fq_name (SemanticGraph::Nameable& n, char const* name_key)
{
using namespace SemanticGraph;
@@ -548,17 +544,17 @@ namespace CXX
escape (String const& name)
{
String r;
- Size n (name.size ());
+ size_t n (name.size ());
// In most common cases we will have that many chars.
//
r.reserve (n);
- for (Size i (0); i < n; ++i)
+ for (size_t i (0); i < n; ++i)
{
- Boolean first (i == 0);
+ bool first (i == 0);
- UnsignedLong u (unicode_char (name, i)); // May advance i.
+ unsigned int u (unicode_char (name, i)); // May advance i.
if (first)
{
@@ -574,7 +570,7 @@ namespace CXX
u == '_'))
r.push_back ('_');
else
- r.push_back (static_cast<WideChar> (u));
+ r.push_back (static_cast<wchar_t> (u));
}
if (r.empty ())
@@ -582,7 +578,7 @@ namespace CXX
// Custom reserved words.
//
- ReservedNameMap::ConstIterator i (reserved_name_map.find (r));
+ ReservedNameMap::const_iterator i (reserved_name_map.find (r));
if (i != reserved_name_map.end ())
{
@@ -618,14 +614,14 @@ namespace CXX
//
String
- charlit (UnsignedLong u)
+ charlit (unsigned int u)
{
String r ("\\x");
- Boolean lead (true);
+ bool lead (true);
- for (Long i (7); i >= 0; --i)
+ for (int i (7); i >= 0; --i)
{
- UnsignedLong x ((u >> (i * 4)) & 0x0F);
+ unsigned int x ((u >> (i * 4)) & 0x0F);
if (lead)
{
@@ -645,7 +641,7 @@ namespace CXX
strlit_ascii (String const& str)
{
String r;
- Size n (str.size ());
+ size_t n (str.size ());
// In most common cases we will have that many chars.
//
@@ -653,11 +649,11 @@ namespace CXX
r += '"';
- Boolean escape (false);
+ bool escape (false);
- for (Size i (0); i < n; ++i)
+ for (size_t i (0); i < n; ++i)
{
- UnsignedLong u (Context::unicode_char (str, i)); // May advance i.
+ unsigned int u (Context::unicode_char (str, i)); // May advance i.
// [128 - ] - unrepresentable
// 127 - \x7F
@@ -738,7 +734,7 @@ namespace CXX
}
default:
{
- r += static_cast<WideChar> (u);
+ r += static_cast<wchar_t> (u);
break;
}
}
@@ -756,7 +752,7 @@ namespace CXX
return r;
}
- const UnsignedLong utf8_first_char_mask[5] =
+ const unsigned int utf8_first_char_mask[5] =
{
0x00, 0x00, 0xC0, 0xE0, 0xF0
};
@@ -765,7 +761,7 @@ namespace CXX
strlit_utf8 (String const& str)
{
String r;
- Size n (str.size ());
+ size_t n (str.size ());
// In most common cases we will have that many chars.
//
@@ -773,11 +769,11 @@ namespace CXX
r += '"';
- Boolean escape (false);
+ bool escape (false);
- for (Size i (0); i < n; ++i)
+ for (size_t i (0); i < n; ++i)
{
- UnsignedLong u (Context::unicode_char (str, i)); // May advance i.
+ unsigned int u (Context::unicode_char (str, i)); // May advance i.
// [128 - ] - UTF-8
// 127 - \x7F
@@ -858,15 +854,15 @@ namespace CXX
}
default:
{
- r += static_cast<WideChar> (u);
+ r += static_cast<wchar_t> (u);
break;
}
}
}
else
{
- UnsignedLong count;
- UnsignedLong tmp[4];
+ unsigned int count (0);
+ unsigned int tmp[4];
if (u < 0x800)
count = 2;
@@ -895,10 +891,13 @@ namespace CXX
case 1:
{
tmp[0] = u | utf8_first_char_mask[count];
+ break;
}
+ default:
+ assert (false);
}
- for (UnsignedLong j (0); j < count; ++j)
+ for (unsigned int j (0); j < count; ++j)
r += charlit (tmp[j]);
escape = true;
@@ -914,7 +913,7 @@ namespace CXX
strlit_iso8859_1 (String const& str)
{
String r;
- Size n (str.size ());
+ size_t n (str.size ());
// In most common cases we will have that many chars.
//
@@ -922,11 +921,11 @@ namespace CXX
r += '"';
- Boolean escape (false);
+ bool escape (false);
- for (Size i (0); i < n; ++i)
+ for (size_t i (0); i < n; ++i)
{
- UnsignedLong u (Context::unicode_char (str, i)); // May advance i.
+ unsigned int u (Context::unicode_char (str, i)); // May advance i.
// [256 - ] - unrepresentable
// [127 - 255] - \xXX
@@ -1007,7 +1006,7 @@ namespace CXX
}
default:
{
- r += static_cast<WideChar> (u);
+ r += static_cast<wchar_t> (u);
break;
}
}
@@ -1034,7 +1033,7 @@ namespace CXX
strlit_utf32 (String const& str)
{
String r;
- Size n (str.size ());
+ size_t n (str.size ());
// In most common cases we will have that many chars.
//
@@ -1042,11 +1041,11 @@ namespace CXX
r += L"L\"";
- Boolean escape (false);
+ bool escape (false);
- for (Size i (0); i < n; ++i)
+ for (size_t i (0); i < n; ++i)
{
- UnsignedLong u (Context::unicode_char (str, i)); // May advance i.
+ unsigned int u (Context::unicode_char (str, i)); // May advance i.
// [128 - ] - \xUUUUUUUU
// 127 - \x7F
@@ -1105,9 +1104,10 @@ namespace CXX
{
if (escape)
{
- // Close and open the string so there are no clashes.
+ // Close and open the string so there are no clashes. C++11
+ // requires a space between " and L.
//
- r += L"\"L\"";
+ r += L"\" L\"";
escape = false;
}
@@ -1125,7 +1125,7 @@ namespace CXX
}
default:
{
- r += static_cast<WideChar> (u);
+ r += static_cast<wchar_t> (u);
break;
}
}
@@ -1148,7 +1148,7 @@ namespace CXX
// First see if we have a custom mapping.
//
assert (string_literal_map != 0);
- StringLiteralMap::ConstIterator i (string_literal_map->find (str));
+ StringLiteralMap::const_iterator i (string_literal_map->find (str));
if (i != string_literal_map->end ())
return i->second;
@@ -1175,16 +1175,16 @@ namespace CXX
{
String r;
- WideChar const* s (str.c_str ());
- Size size (str.size ());
+ wchar_t const* s (str.c_str ());
+ size_t size (str.size ());
// In most common cases we will have that many chars.
//
r.reserve (size);
- for (WideChar const* p (s); p < s + size; ++p)
+ for (wchar_t const* p (s); p < s + size; ++p)
{
- UnsignedLong u (unicode_char (p)); // May advance p.
+ unsigned int u (unicode_char (p)); // May advance p.
// We are going to treat \v, \f and \n as unrepresentable
// here even though they can be present in C++ source code.
@@ -1192,7 +1192,7 @@ namespace CXX
if (u > 127 || (u < 32 && u != '\t'))
r += L'?';
else
- r += static_cast<WideChar> (u);
+ r += static_cast<wchar_t> (u);
}
return r;
@@ -1201,30 +1201,31 @@ namespace CXX
String Context::
process_include_path (String const& name) const
{
- String path (include_prefix + name);
+ String path (String (options.include_prefix ()) + name);
+ bool trace (options.include_regex_trace ());
- if (trace_include_regex)
+ if (trace)
wcerr << "include: '" << path << "'" << endl;
String r;
- Boolean found (false);
+ bool found (false);
- for (RegexMapping::ConstReverseIterator e (include_mapping.rbegin ());
+ for (RegexMapping::const_reverse_iterator e (include_mapping.rbegin ());
e != include_mapping.rend (); ++e)
{
- if (trace_include_regex)
- wcerr << "try: '" << e->pattern () << "' : ";
+ if (trace)
+ wcerr << "try: '" << e->regex () << "' : ";
if (e->match (path))
{
- r = e->merge (path);
+ r = e->replace (path);
found = true;
- if (trace_include_regex)
+ if (trace)
wcerr << "'" << r << "' : ";
}
- if (trace_include_regex)
+ if (trace)
wcerr << (found ? '+' : '-') << endl;
if (found)
@@ -1236,8 +1237,8 @@ namespace CXX
if (!r.empty () && r[0] != L'"' && r[0] != L'<')
{
- WideChar op (include_with_brackets ? L'<' : L'"');
- WideChar cl (include_with_brackets ? L'>' : L'"');
+ wchar_t op (options.include_with_brackets () ? L'<' : L'"');
+ wchar_t cl (options.include_with_brackets () ? L'>' : L'"');
r = op + r + cl;
}
@@ -1247,7 +1248,7 @@ namespace CXX
// Namespace
//
- Void Namespace::
+ void Namespace::
pre (Type& n)
{
String ns (ctx_.ns_name (n));
@@ -1281,7 +1282,7 @@ namespace CXX
} while (true);
}
- Void Namespace::
+ void Namespace::
post (Type& n)
{
String ns (ctx_.ns_name (n));
diff --git a/xsd/xsd/cxx/elements.hxx b/xsd/xsd/cxx/elements.hxx
index 59938c5..4b36da9 100644
--- a/xsd/xsd/cxx/elements.hxx
+++ b/xsd/xsd/cxx/elements.hxx
@@ -1,31 +1,29 @@
// file : xsd/cxx/elements.hxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#ifndef CXX_ELEMENTS_HXX
#define CXX_ELEMENTS_HXX
+#include <set>
+#include <map>
+#include <vector>
#include <ostream>
-#include <cult/types.hxx>
-#include <cult/containers/set.hxx>
-#include <cult/containers/map.hxx>
-#include <cult/containers/vector.hxx>
-
-#include <backend-elements/regex.hxx>
+#include <cutl/re.hxx>
#include <xsd-frontend/semantic-graph.hxx>
#include <xsd-frontend/traversal.hxx>
+#include <types.hxx>
#include <elements.hxx>
+
+#include <cxx/options.hxx>
#include <cxx/literal-map.hxx>
namespace CXX
{
using std::endl;
- typedef WideString String;
-
// On some platforms std::toupper can be something other than a
// function with C++ linkage.
@@ -39,7 +37,7 @@ namespace CXX
struct UnrepresentableCharacter
{
- UnrepresentableCharacter (String const& str, Size pos)
+ UnrepresentableCharacter (String const& str, size_t pos)
: str_ (str), pos_ (pos)
{
}
@@ -50,7 +48,7 @@ namespace CXX
return str_;
}
- Size
+ size_t
position () const
{
return pos_;
@@ -58,14 +56,14 @@ namespace CXX
private:
String str_;
- Size pos_;
+ size_t pos_;
};
struct NoNamespaceMapping
{
NoNamespaceMapping (SemanticGraph::Path const& file,
- UnsignedLong line,
- UnsignedLong column,
+ size_t line,
+ size_t column,
String const& ns)
: file_ (file),
line_ (line),
@@ -81,13 +79,13 @@ namespace CXX
return file_;
}
- UnsignedLong
+ size_t
line () const
{
return line_;
}
- UnsignedLong
+ size_t
column () const
{
return column_;
@@ -101,8 +99,8 @@ namespace CXX
private:
SemanticGraph::Path file_;
- UnsignedLong line_;
- UnsignedLong column_;
+ size_t line_;
+ size_t column_;
String ns_;
};
@@ -136,57 +134,47 @@ namespace CXX
class Context
{
public:
- typedef BackendElements::Regex::Pattern<WideChar> RegexPat;
- typedef BackendElements::Regex::Expression<WideChar> Regex;
- typedef Cult::Containers::Vector<Regex> RegexMapping;
- typedef Cult::Containers::Map<String, String> MapMapping;
- typedef Cult::Containers::Map<String, String> MappingCache;
+ typedef cutl::re::wregex RegexPat;
+ typedef cutl::re::wregexsub Regex;
+ typedef std::vector<Regex> RegexMapping;
+ typedef std::map<String, String> MapMapping;
+ typedef std::map<String, String> MappingCache;
- typedef Cult::Containers::Map<String, String> ReservedNameMap;
- typedef Cult::Containers::Set<String> KeywordSet;
+ typedef std::map<String, String> ReservedNameMap;
+ typedef std::set<String> KeywordSet;
+
+ typedef CXX::options options_type;
public:
Context (std::wostream& o,
SemanticGraph::Schema& root,
SemanticGraph::Path const& path,
- StringLiteralMap const* custom_literals_map,
- NarrowString const& char_type__,
- NarrowString const& char_encoding__,
- Boolean include_with_brackets__,
- NarrowString const& include_prefix__,
- NarrowString const& esymbol,
- Containers::Vector<NarrowString> const& nsm,
- Containers::Vector<NarrowString> const& nsr,
- Boolean trace_namespace_regex_,
- Containers::Vector<NarrowString> const& include_regex,
- Boolean trace_include_regex_,
- Boolean inline_,
- Containers::Vector<NarrowString> const& reserved_name);
+ options_type const& ops,
+ StringLiteralMap const* custom_literals_map);
protected:
Context (Context& c)
: os (c.os),
schema_root (c.schema_root),
schema_path (c.schema_path),
+ options (c.options),
+ std (c.std),
char_type (c.char_type),
char_encoding (c.char_encoding),
L (c.L),
string_type (c.string_type),
+ auto_ptr (c.auto_ptr),
string_literal_map (c.string_literal_map),
- include_with_brackets (c.include_with_brackets),
- include_prefix (c.include_prefix),
type_exp (c.type_exp),
inst_exp (c.inst_exp),
inl (c.inl),
ns_mapping_cache (c.ns_mapping_cache),
xs_ns_ (c.xs_ns_),
cxx_id_expr (c.cxx_id_expr),
- trace_namespace_regex (c.trace_namespace_regex),
urn_mapping (c.urn_mapping),
nsr_mapping (c.nsr_mapping),
nsm_mapping (c.nsm_mapping),
include_mapping (c.include_mapping),
- trace_include_regex (c.trace_include_regex),
reserved_name_map (c.reserved_name_map),
keyword_set (c.keyword_set)
{
@@ -196,25 +184,24 @@ namespace CXX
: os (o),
schema_root (c.schema_root),
schema_path (c.schema_path),
+ options (c.options),
+ std (c.std),
char_type (c.char_type),
char_encoding (c.char_encoding),
L (c.L),
string_type (c.string_type),
+ auto_ptr (c.auto_ptr),
string_literal_map (c.string_literal_map),
- include_with_brackets (c.include_with_brackets),
- include_prefix (c.include_prefix),
type_exp (c.type_exp),
inst_exp (c.inst_exp),
inl (c.inl),
ns_mapping_cache (c.ns_mapping_cache),
xs_ns_ (c.xs_ns_),
cxx_id_expr (c.cxx_id_expr),
- trace_namespace_regex (c.trace_namespace_regex),
urn_mapping (c.urn_mapping),
nsr_mapping (c.nsr_mapping),
nsm_mapping (c.nsm_mapping),
include_mapping (c.include_mapping),
- trace_include_regex (c.trace_include_regex),
reserved_name_map (c.reserved_name_map),
keyword_set (c.keyword_set)
{
@@ -232,11 +219,11 @@ namespace CXX
// advanced by 1 if this Unicode character takes more than one
// underlying character.
//
- static UnsignedLong
- unicode_char (String const& str, Size& pos);
+ static unsigned int
+ unicode_char (String const& str, size_t& pos);
- static UnsignedLong
- unicode_char (WideChar const*& p);
+ static unsigned int
+ unicode_char (wchar_t const*& p);
// Escape C++ keywords and illegal characters.
//
@@ -283,7 +270,7 @@ namespace CXX
// Fully-qualified C++ name.
//
String
- fq_name (SemanticGraph::Nameable& n, Char const* name_key = "name");
+ fq_name (SemanticGraph::Nameable& n, char const* name_key = "name");
public:
static SemanticGraph::Type&
@@ -294,7 +281,7 @@ namespace CXX
process_include_path (String const&) const;
public:
- static Boolean
+ static bool
skip (SemanticGraph::Member& m)
{
// "Subsequent" local element.
@@ -303,28 +290,28 @@ namespace CXX
m.context ().count ("min") == 0;
}
- static UnsignedLong
+ static size_t
min (SemanticGraph::Member const& m)
{
- return m.context ().get<UnsignedLong> ("min");
+ return m.context ().get<size_t> ("min");
}
- static UnsignedLong
+ static size_t
min (SemanticGraph::Any const& a)
{
- return a.context ().get<UnsignedLong> ("min");
+ return a.context ().get<size_t> ("min");
}
- static UnsignedLong
+ static size_t
max (SemanticGraph::Member const& m)
{
- return m.context ().get<UnsignedLong> ("max");
+ return m.context ().get<size_t> ("max");
}
- static UnsignedLong
+ static size_t
max (SemanticGraph::Any const& a)
{
- return a.context ().get<UnsignedLong> ("max");
+ return a.context ().get<size_t> ("max");
}
public:
@@ -342,14 +329,17 @@ namespace CXX
SemanticGraph::Schema& schema_root;
SemanticGraph::Path const& schema_path;
+ options_type const& options;
+
+ cxx_version std;
+
String& char_type;
String& char_encoding;
String& L; // string literal prefix
String& string_type;
- StringLiteralMap const* string_literal_map;
+ String& auto_ptr;
- Boolean& include_with_brackets;
- String& include_prefix;
+ StringLiteralMap const* string_literal_map;
String& type_exp;
String& inst_exp;
@@ -367,9 +357,7 @@ namespace CXX
String char_encoding_;
String L_;
String string_type_;
-
- Boolean include_with_brackets_;
- String include_prefix_;
+ String auto_ptr_;
String type_exp_;
String inst_exp_;
@@ -378,7 +366,6 @@ namespace CXX
private:
RegexPat const cxx_id_expr_;
RegexPat const& cxx_id_expr;
- Boolean trace_namespace_regex;
Regex urn_mapping_;
RegexMapping nsr_mapping_;
MapMapping nsm_mapping_;
@@ -389,7 +376,6 @@ namespace CXX
RegexMapping include_mapping_;
RegexMapping const& include_mapping;
- Boolean trace_include_regex;
ReservedNameMap const& reserved_name_map;
ReservedNameMap reserved_name_map_;
@@ -398,16 +384,16 @@ namespace CXX
KeywordSet keyword_set_;
};
- inline UnsignedLong Context::
- unicode_char (String const& str, Size& pos)
+ inline unsigned int Context::
+ unicode_char (String const& str, size_t& pos)
{
- if (sizeof (WideChar) == 4)
+ if (sizeof (wchar_t) == 4)
{
return str[pos];
}
- else if (sizeof (WideChar) == 2)
+ else if (sizeof (wchar_t) == 2)
{
- WideChar x (str[pos]);
+ wchar_t x (str[pos]);
if (x < 0xD800 || x > 0xDBFF)
return x;
@@ -418,16 +404,16 @@ namespace CXX
return 0;
}
- inline UnsignedLong Context::
- unicode_char (WideChar const*& p)
+ inline unsigned int Context::
+ unicode_char (wchar_t const*& p)
{
- if (sizeof (WideChar) == 4)
+ if (sizeof (wchar_t) == 4)
{
return *p;
}
- else if (sizeof (WideChar) == 2)
+ else if (sizeof (wchar_t) == 2)
{
- WideChar x (*p);
+ wchar_t x (*p);
if (x < 0xD800 || x > 0xDBFF)
return x;
@@ -438,6 +424,21 @@ namespace CXX
return 0;
}
+ // Sources traverser that goes into each schema only once.
+ //
+ struct Sources: Traversal::Sources
+ {
+ virtual void
+ traverse (SemanticGraph::Sources& s)
+ {
+ if (schemas_.insert (&s.schema ()).second)
+ Traversal::Sources::traverse (s);
+ }
+
+ private:
+ std::set<SemanticGraph::Schema*> schemas_;
+ };
+
// Usual namespace mapping.
//
struct Namespace: Traversal::Namespace
@@ -447,10 +448,10 @@ namespace CXX
// First scope name if always empty (global scope). The last flag
// signals the last scope.
//
- virtual Void
- enter (Type&, String const& name, Boolean last) = 0;
+ virtual void
+ enter (Type&, String const& name, bool last) = 0;
- virtual Void
+ virtual void
leave () = 0;
};
@@ -465,10 +466,10 @@ namespace CXX
{
}
- virtual Void
+ virtual void
pre (Type&);
- virtual Void
+ virtual void
post (Type&);
private:
@@ -476,36 +477,35 @@ namespace CXX
ScopeTracker* st_;
};
-
//
//
template <typename X>
struct Has : X
{
- Has (Boolean& result)
+ Has (bool& result)
: result_ (result)
{
}
- virtual Void
+ virtual void
traverse (typename X::Type&)
{
result_ = true;
}
private:
- Boolean& result_;
+ bool& result_;
};
// Checks if scope 'Y' names any of 'X'
//
template <typename X, typename Y>
- Boolean
+ bool
has (Y& y)
{
using SemanticGraph::Scope;
- Boolean result (false);
+ bool result (false);
Has<X> t (result);
for (Scope::NamesIterator i (y.names_begin ()), e (y.names_end ());
@@ -518,12 +518,12 @@ namespace CXX
// Checks if the compositor has any particle of 'X'
//
template <typename X>
- Boolean
+ bool
has_particle (SemanticGraph::Compositor& y)
{
using SemanticGraph::Compositor;
- Boolean result (false);
+ bool result (false);
Has<X> t (result);
for (Compositor::ContainsIterator i (y.contains_begin ()),
@@ -543,7 +543,7 @@ namespace CXX
// Specialization for Complex
//
template <typename X>
- Boolean
+ bool
has_particle (SemanticGraph::Complex& c)
{
return c.contains_compositor_p () &&
@@ -562,61 +562,61 @@ namespace CXX
Traversal::Fundamental::Id,
Traversal::Fundamental::IdRef
{
- virtual Void
+ virtual void
fundamental_type (SemanticGraph::Fundamental::Type& t) = 0;
- virtual Void
+ virtual void
fundamental_template (SemanticGraph::Fundamental::Type& t) = 0;
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Type& t)
{
fundamental_type (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::String& t)
{
fundamental_template (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NormalizedString& t)
{
fundamental_template (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Token& t)
{
fundamental_template (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Name& t)
{
fundamental_template (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NameToken& t)
{
fundamental_template (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NCName& t)
{
fundamental_template (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Id& t)
{
fundamental_template (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::IdRef& t)
{
fundamental_template (t);
diff --git a/xsd/xsd/cxx/literal-map.cxx b/xsd/xsd/cxx/literal-map.cxx
index c531b5e..24bfc52 100644
--- a/xsd/xsd/cxx/literal-map.cxx
+++ b/xsd/xsd/cxx/literal-map.cxx
@@ -1,6 +1,5 @@
// file : xsd/cxx/literal-map.cxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#include <memory> // std::auto_ptr
@@ -9,7 +8,6 @@
#include <iostream>
#include <xercesc/util/XMLUni.hpp>
-#include <xercesc/util/XercesVersion.hpp>
#include <xercesc/framework/LocalFileInputSource.hpp>
@@ -45,7 +43,7 @@ namespace CXX
locator_ = l;
}
- virtual Void
+ virtual void
startElement (const XMLCh* const,
const XMLCh* const lname,
const XMLCh* const,
@@ -81,7 +79,7 @@ namespace CXX
}
}
- virtual Void
+ virtual void
endElement (const XMLCh* const,
const XMLCh* const lname,
const XMLCh* const)
@@ -115,13 +113,8 @@ namespace CXX
state_ = s_entry;
}
-#if _XERCES_VERSION >= 30000
- virtual Void
+ virtual void
characters (const XMLCh* const s, const XMLSize_t length)
-#else
- virtual Void
- characters (const XMLCh* const s, const unsigned int length)
-#endif
{
String str (XML::transcode (s, length));
@@ -131,9 +124,9 @@ namespace CXX
lit_ += str;
else
{
- for (Size i (0); i < str.size (); ++i)
+ for (size_t i (0); i < str.size (); ++i)
{
- WideChar c (str[i]);
+ wchar_t c (str[i]);
if (c != 0x20 && c != 0x0A && c != 0x0D && c != 0x09)
{
@@ -149,44 +142,37 @@ namespace CXX
//
enum Severity {s_warning, s_error, s_fatal};
- virtual Void
+ virtual void
warning (const SAXParseException& e)
{
handle (e, s_warning);
}
- virtual Void
+ virtual void
error (const SAXParseException& e)
{
handle (e, s_error);
}
- virtual Void
+ virtual void
fatalError (const SAXParseException& e)
{
handle (e, s_fatal);
}
- virtual Void
+ virtual void
resetErrors ()
{
}
- Void
+ void
handle (const SAXParseException& e, Severity s)
{
- wcerr << file_ << ":";
-
-#if _XERCES_VERSION >= 30000
- wcerr << e.getLineNumber () << ":" << e.getColumnNumber () << ": ";
-#else
- XMLSSize_t l (e.getLineNumber ());
- XMLSSize_t c (e.getColumnNumber ());
- wcerr << (l == -1 ? 0 : l) << ":" << (c == -1 ? 0 : c) << ": ";
-#endif
-
String msg (XML::transcode (e.getMessage ()));
- wcerr << (s == s_warning ? "warning: " : "error: ") << msg << endl;
+
+ wcerr << file_ << ":"
+ << e.getLineNumber () << ":" << e.getColumnNumber () << ": "
+ << (s == s_warning ? "warning: " : "error: ") << msg << endl;
if (s != s_warning)
throw Failed ();
@@ -195,37 +181,17 @@ namespace CXX
size_t
line () const
{
- size_t r (0);
-
- if (locator_ != 0)
- {
-#if _XERCES_VERSION >= 30000
- r = static_cast<size_t> (locator_->getLineNumber ());
-#else
- XMLSSize_t l (locator_->getLineNumber ());
- r = l == -1 ? 0 : static_cast<size_t> (l);
-#endif
- }
-
- return r;
+ return locator_ != 0
+ ? static_cast<size_t> (locator_->getLineNumber ())
+ : 0;
}
size_t
col () const
{
- size_t r (0);
-
- if (locator_ != 0)
- {
-#if _XERCES_VERSION >= 30000
- r = static_cast<size_t> (locator_->getColumnNumber ());
-#else
- XMLSSize_t c (locator_->getColumnNumber ());
- r = c == -1 ? 0 : static_cast<size_t> (c);
-#endif
- }
-
- return r;
+ return locator_ != 0
+ ? static_cast<size_t> (locator_->getColumnNumber ())
+ : 0;
}
private:
@@ -243,8 +209,8 @@ namespace CXX
String file_;
StringLiteralMap& map_;
- Boolean str_seen_;
- Boolean lit_seen_;
+ bool str_seen_;
+ bool lit_seen_;
String str_;
String lit_;
diff --git a/xsd/xsd/cxx/literal-map.hxx b/xsd/xsd/cxx/literal-map.hxx
index 6edeb00..987a531 100644
--- a/xsd/xsd/cxx/literal-map.hxx
+++ b/xsd/xsd/cxx/literal-map.hxx
@@ -1,20 +1,17 @@
// file : xsd/cxx/literal-map.hxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#ifndef CXX_LITERAL_MAP_HXX
#define CXX_LITERAL_MAP_HXX
-#include <cult/types.hxx>
-#include <cult/containers/map.hxx>
+#include <map>
+
+#include <types.hxx>
namespace CXX
{
- using namespace Cult;
- typedef WideString String;
-
- typedef Cult::Containers::Map<String, String> StringLiteralMap;
+ typedef std::map<String, String> StringLiteralMap;
bool
read_literal_map (NarrowString const& file, StringLiteralMap& map);
diff --git a/xsd/xsd/cxx/option-types.cxx b/xsd/xsd/cxx/option-types.cxx
new file mode 100644
index 0000000..78424f0
--- /dev/null
+++ b/xsd/xsd/cxx/option-types.cxx
@@ -0,0 +1,48 @@
+// file : xsd/cxx/option-types.cxx
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#include <istream>
+#include <ostream>
+
+#include <cxx/option-types.hxx>
+
+using namespace std;
+
+namespace CXX
+{
+ //
+ // cxx_version
+ //
+
+ static const char* cxx_version_[] =
+ {
+ "c++98",
+ "c++11"
+ };
+
+ string cxx_version::
+ string () const
+ {
+ return cxx_version_[v_];
+ }
+
+ istream&
+ operator>> (istream& is, cxx_version& v)
+ {
+ string s;
+ is >> s;
+
+ if (!is.fail ())
+ {
+ if (s == "c++98")
+ v = cxx_version::cxx98;
+ else if (s == "c++11")
+ v = cxx_version::cxx11;
+ else
+ is.setstate (istream::failbit);
+ }
+
+ return is;
+ }
+}
diff --git a/xsd/xsd/cxx/option-types.hxx b/xsd/xsd/cxx/option-types.hxx
new file mode 100644
index 0000000..b2377ba
--- /dev/null
+++ b/xsd/xsd/cxx/option-types.hxx
@@ -0,0 +1,35 @@
+// file : xsd/cxx/option-types.hxx
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#ifndef XSD_OPTION_TYPES_HXX
+#define XSD_OPTION_TYPES_HXX
+
+#include <iosfwd>
+#include <string>
+
+namespace CXX
+{
+ struct cxx_version
+ {
+ enum value
+ {
+ cxx98,
+ cxx11
+ };
+
+ cxx_version (value v = value (0)) : v_ (v) {}
+ operator value () const {return v_;}
+
+ std::string
+ string () const;
+
+ private:
+ value v_;
+ };
+
+ std::istream&
+ operator>> (std::istream&, cxx_version&);
+}
+
+#endif // XSD_OPTION_TYPES_HXX
diff --git a/xsd/xsd/cxx/options.cli b/xsd/xsd/cxx/options.cli
new file mode 100644
index 0000000..8133b25
--- /dev/null
+++ b/xsd/xsd/cxx/options.cli
@@ -0,0 +1,551 @@
+// file : xsd/cxx/options.cli
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+include <cstddef>; // std::size_t
+
+include <types.hxx>; // NarrowString, NarrowStrings
+
+include <cxx/option-types.hxx>;
+
+include <options.cli>;
+
+namespace CXX
+{
+ class options: ::options = 0
+ {
+ // Language.
+ //
+ cxx_version --std = cxx_version::cxx98
+ {
+ "<version>",
+ "Specify the C++ standard that the generated code should conform to.
+ Valid values are \cb{c++98} (default) and \cb{c++11}.
+
+ The C++ standard affects various aspects of the generated code that
+ are discussed in more detail in various mapping-specific
+ documentation. Overall, when C++11 is selected, the generated
+ code relies on the move semantics and uses \cb{std::unique_ptr}
+ instead of deprecated \cb{std::auto_ptr}.
+
+ When the C++11 mode is selected, you normally don't need to
+ perform any extra steps other than enable C++11 in your C++
+ compiler, if required. The XSD compiler will automatically
+ add the necessary macro defines to the generated header files
+ that will switch the header-only XSD runtime library (\cb{libxsd})
+ to the C++11 mode. However, if you include any of the XSD runtime
+ headers directly in your application (normally you just include
+ the generated headers), then you will need to define the
+ \cb{XSD_CXX11} macro for your entire project."
+ };
+
+ // Character type and encoding.
+ //
+ NarrowString --char-type = "char"
+ {
+ "<type>",
+ "Generate code using the provided character <type> instead of the
+ default \cb{char}. Valid values are \cb{char} and \cb{wchar_t}."
+ };
+
+ NarrowString --char-encoding
+ {
+ "<enc>",
+ "Specify the character encoding that should be used in the generated
+ code. Valid values for the \cb{char} character type are \cb{utf8}
+ (default), \cb{iso8859-1}, \cb{lcp} (Xerces-C++ local code page),
+ and \cb{custom}. If you pass \cb{custom} as the value then you will
+ need to include the transcoder implementation header for your
+ encoding at the beginning of the generated header files (see the
+ \cb{--hxx-prologue} option).
+
+ For the \cb{wchar_t} character type the only valid value is \cb{auto}
+ and the encoding is automatically selected between UTF-16 and
+ UTF-32/UCS-4, depending on the \cb{wchar_t} type size."
+ };
+
+ // Output options.
+ //
+ NarrowString --output-dir
+ {
+ "<dir>",
+ "Write generated files to <dir> instead of the current directory."
+ };
+
+ bool --generate-inline
+ {
+ "Generate simple functions inline. This option triggers creation of
+ the inline file."
+ };
+
+ // Extern XML Schema.
+ //
+ bool --generate-xml-schema
+ {
+ "Generate a C++ header file as if the schema being compiled defines the
+ XML Schema namespace. For the C++/Tree mapping, the resulting file will
+ contain definitions for all XML Schema built-in types. For the
+ C++/Parser mapping, the resulting file will contain definitions for
+ all the parser skeletons and implementations corresponding to the
+ XML Schema built-in types.
+
+ The schema file provided to the compiler need not exist and is only
+ used to derive the name of the resulting header file. Use the
+ \cb{--extern-xml-schema} option to include this file in the
+ generated files for other schemas."
+ };
+
+ NarrowString --extern-xml-schema
+ {
+ "<file>",
+ "Include a header file derived from <file> instead of generating the
+ XML Schema namespace mapping inline. The provided file need not
+ exist and is only used to derive the name of the included header
+ file. Use the \cb{--generate-xml-schema} option to generate this
+ header file."
+ };
+
+ // Namespace mapping.
+ //
+ NarrowStrings --namespace-map
+ {
+ "<xns>=<cns>",
+ "Map XML Schema namespace <xns> to C++ namespace <cns>. Repeat
+ this option to specify mapping for more than one XML Schema namespace.
+ For example, the following option:
+
+ \cb{--namespace-map http://example.com/foo/bar=foo::bar}
+
+ Will map the \cb{http://example.com/foo/bar} XML Schema namespace to
+ the \cb{foo::bar} C++ namespace."
+ };
+
+ NarrowStrings --namespace-regex
+ {
+ "<regex>",
+ "Add <regex> to the list of regular expressions used to translate XML
+ Schema namespace names to C++ namespace names. <regex> is a Perl-like
+ regular expression in the form
+ \c{\b{/}\i{pattern}\b{/}\i{replacement}\b{/}}. Any character can be
+ used as a delimiter instead of \cb{/}. Escaping of the delimiter
+ character in \ci{pattern} or \ci{replacement} is not supported.
+
+ All the regular expressions are pushed into a stack with the last
+ specified expression considered first. The first match that
+ succeeds is used. Regular expressions are applied to a string in
+ the form
+
+ \c{\i{filename} \i{namespace}}
+
+ For example, if you have file \cb{hello.xsd} with namespace
+ \cb{http://example.com/hello} and you run \cb{xsd} on this file,
+ then the string in question will be:
+
+ \cb{hello.xsd. http://example.com/hello}
+
+ For the built-in XML Schema namespace the string is:
+
+ \cb{XMLSchema.xsd http://www.w3.org/2001/XMLSchema}
+
+ The following three steps are performed for each regular expression
+ until the match is found:
+
+ 1. The expression is applied and if the result is empty the next
+ expression is considered.
+
+ 2. All \cb{/} are replaced with \cb{::}.
+
+ 3. The result is verified to be a valid C++ scope name (e.g.,
+ \cb{foo::bar}). If this test succeeds, the result is used as a
+ C++ namespace name.
+
+ As an example, the following expression maps XML Schema namespaces
+ in the form \cb{http://example.com/foo/bar} to C++ namespaces in the
+ form \cb{foo::bar}:
+
+ \cb{%.* http://example.com/(.+)%$1%}
+
+ See also the REGEX AND SHELL QUOTING section below."
+ };
+
+ bool --namespace-regex-trace
+ {
+ "Trace the process of applying regular expressions specified with the
+ \cb{--namespace-regex} option. Use this option to find out why your
+ regular expressions don't do what you expected them to do."
+ };
+
+ // Reserved names.
+ //
+ NarrowStrings --reserved-name
+ {
+ "<n>[=<r>]",
+ "Add name <n> to the list of names that should not be used as
+ identifiers. The name can optionally be followed by \cb{=} and the
+ replacement name <r> that should be used instead. All the C++ keywords
+ are already in this list."
+ };
+
+ // Include options.
+ //
+ bool --include-with-brackets
+ {
+ "Use angle brackets (<>) instead of quotes (\"\") in generated
+ \cb{#include} directives."
+ };
+
+ NarrowString --include-prefix
+ {
+ "<prefix>",
+ "Add <prefix> to generated \cb{#include} directive paths.
+
+ For example, if you had the following import element in your schema
+
+ \cb{<import namespace=\"...\" schemaLocation=\"base.xsd\"/>}
+
+ and compiled this fragment with \cb{--include-prefix schemas/}, then
+ the include directive in the generated code would be:
+
+ \cb{#include \"schemas/base.hxx\"}"
+ };
+
+ NarrowStrings --include-regex
+ {
+ "<regex>",
+ "Add <regex> to the list of regular expressions used to transform
+ \cb{#include} directive paths. <regex> is a Perl-like regular
+ expression in the form \c{\b{/}\i{pattern}\b{/}\i{replacement}\b{/}}.
+ Any character can be used as a delimiter instead of \cb{/}. Escaping
+ of the delimiter character in \ci{pattern} or \ci{replacement} is not
+ supported.
+
+ All the regular expressions are pushed into a stack with the last
+ specified expression considered first. The first match that succeeds
+ is used.
+
+ As an example, the following expression transforms paths in the form
+ \cb{schemas/foo/bar} to paths in the form \cb{generated/foo/bar}:
+
+ \cb{%schemas/(.+)%generated/$1%}
+
+ See also the REGEX AND SHELL QUOTING section below."
+ };
+
+ bool --include-regex-trace
+ {
+ "Trace the process of applying regular expressions specified with the
+ \cb{--include-regex} option. Use this option to find out why your
+ regular expressions don't do what you expected them to do."
+ };
+
+ NarrowString --guard-prefix
+ {
+ "<prefix>",
+ "Add <prefix> to generated header inclusion guards. The prefix is
+ transformed to upper case and characters that are illegal in a
+ preprocessor macro name are replaced with underscores. If this
+ option is not specified then the directory part of the input schema
+ file is used as a prefix."
+ };
+
+ // File suffixes.
+ //
+ NarrowString --hxx-suffix = ".hxx"
+ {
+ "<suffix>",
+ "Use the provided <suffix> instead of the default \cb{.hxx} to
+ construct the name of the header file. Note that this suffix is also
+ used to construct names of header files corresponding to
+ included/imported schemas."
+ };
+
+ NarrowString --ixx-suffix = ".ixx"
+ {
+ "<suffix>",
+ "Use the provided <suffix> instead of the default \cb{.ixx} to
+ construct the name of the inline file."
+ };
+
+ NarrowString --cxx-suffix = ".cxx"
+ {
+ "<suffix>",
+ "Use the provided <suffix> instead of the default \cb{.cxx} to
+ construct the name of the source file."
+ };
+
+ NarrowString --fwd-suffix = "-fwd.hxx"
+ {
+ "<suffix>",
+ "Use the provided <suffix> instead of the default \cb{-fwd.hxx} to
+ construct the name of the forward declaration file."
+ };
+
+ NarrowString --hxx-regex
+ {
+ "<regex>",
+ "Use the provided expression to construct the name of the header file.
+ <regex> is a Perl-like regular expression in the form
+ \c{\b{/}\i{pattern}\b{/}\i{replacement}\b{/}}.
+ Note that this expression is also used to construct names of header
+ files corresponding to included/imported schemas. See also the REGEX
+ AND SHELL QUOTING section below."
+ };
+
+ NarrowString --ixx-regex
+ {
+ "<regex>",
+ "Use the provided expression to construct the name of the inline file.
+ <regex> is a Perl-like regular expression in the form
+ \c{\b{/}\i{pattern}\b{/}\i{replacement}\b{/}}. See also the REGEX AND
+ SHELL QUOTING section below."
+ };
+
+ NarrowString --cxx-regex
+ {
+ "<regex>",
+ "Use the provided expression to construct the name of the source file.
+ <regex> is a Perl-like regular expression in the form
+ \c{\b{/}\i{pattern}\b{/}\i{replacement}\b{/}}. See also the REGEX AND
+ SHELL QUOTING section below."
+ };
+
+ NarrowString --fwd-regex
+ {
+ "<regex>",
+ "Use the provided expression to construct the name of the forward
+ declaration file. <regex> is a Perl-like regular expression in the
+ form \c{\b{/}\i{pattern}\b{/}\i{replacement}\b{/}}. See also the REGEX
+ AND SHELL QUOTING section below."
+ };
+
+ // Prologues/epilogues.
+ //
+ NarrowStrings --hxx-prologue
+ {
+ "<text>",
+ "Insert <text> at the beginning of the header file."
+ };
+
+ NarrowStrings --ixx-prologue
+ {
+ "<text>",
+ "Insert <text> at the beginning of the inline file."
+ };
+
+ NarrowStrings --cxx-prologue
+ {
+ "<text>",
+ "Insert <text> at the beginning of the source file."
+ };
+
+ NarrowStrings --fwd-prologue
+ {
+ "<text>",
+ "Insert <text> at the beginning of the forward declaration file."
+ };
+
+ NarrowStrings --prologue
+ {
+ "<text>",
+ "Insert <text> at the beginning of each generated file for which
+ there is no file-specific prologue."
+ };
+
+ NarrowStrings --hxx-epilogue
+ {
+ "<text>",
+ "Insert <text> at the end of the header file."
+ };
+
+ NarrowStrings --ixx-epilogue
+ {
+ "<text>",
+ "Insert <text> at the end of the inline file."
+ };
+
+ NarrowStrings --cxx-epilogue
+ {
+ "<text>",
+ "Insert <text> at the end of the source file."
+ };
+
+ NarrowStrings --fwd-epilogue
+ {
+ "<text>",
+ "Insert <text> at the end of the forward declaration file."
+ };
+
+ NarrowStrings --epilogue
+ {
+ "<text>",
+ "Insert <text> at the end of each generated file for which there
+ is no file-specific epilogue."
+ };
+
+ NarrowString --hxx-prologue-file
+ {
+ "<file>",
+ "Insert the content of the <file> at the beginning of the header file."
+ };
+
+ NarrowString --ixx-prologue-file
+ {
+ "<file>",
+ "Insert the content of the <file> at the beginning of the inline file."
+ };
+
+ NarrowString --cxx-prologue-file
+ {
+ "<file>",
+ "Insert the content of the <file> at the beginning of the source file."
+ };
+
+ NarrowString --fwd-prologue-file
+ {
+ "<file>",
+ "Insert the content of the <file> at the beginning of the forward
+ declaration file."
+ };
+
+ NarrowString --prologue-file
+ {
+ "<file>",
+ "Insert the content of the <file> at the beginning of each generated
+ file for which there is no file-specific prologue file."
+ };
+
+ NarrowString --hxx-epilogue-file
+ {
+ "<file>",
+ "Insert the content of the <file> at the end of the header file."
+ };
+
+ NarrowString --ixx-epilogue-file
+ {
+ "<file>",
+ "Insert the content of the <file> at the end of the inline file."
+ };
+
+ NarrowString --cxx-epilogue-file
+ {
+ "<file>",
+ "Insert the content of the <file> at the end of the source file."
+ };
+
+ NarrowString --fwd-epilogue-file
+ {
+ "<file>",
+ "Insert the content of the <file> at the end of the forward declaration
+ file."
+ };
+
+ NarrowString --epilogue-file
+ {
+ "<file>",
+ "Insert the content of the <file> at the end of each generated file
+ for which there is no file-specific epilogue file."
+ };
+
+ // Export options.
+ //
+ NarrowString --export-symbol
+ {
+ "<symbol>",
+ "Insert <symbol> in places where DLL export/import control statements
+ (\cb{__declspec(dllexport/dllimport)}) are necessary."
+ };
+
+ bool --export-xml-schema
+ {
+ "Export/import types in the XML Schema namespace using the export
+ symbol provided with the \cb{--export-symbol} option. The
+ \cb{XSD_NO_EXPORT} macro can be used to omit this code during C++
+ compilation, which may be useful if you would like to use the same
+ generated code across multiple platforms."
+ };
+
+ bool --export-maps
+ {
+ "Export polymorphism support maps from a Win32 DLL into which this
+ generated code is placed. This is necessary when your type hierarchy
+ is split across several DLLs since otherwise each DLL will have its
+ own set of maps. In this situation the generated code for the DLL
+ which contains base types and/or substitution group heads should be
+ compiled with this option and the generated code for all other DLLs
+ should be compiled with \cb{--import-maps}. This option is only valid
+ together with \cb{--generate-polymorphic}. The \cb{XSD_NO_EXPORT}
+ macro can be used to omit this code during C++ compilation, which may
+ be useful if you would like to use the same generated code across
+ multiple platforms."
+ };
+
+ bool --import-maps
+ {
+ "Import polymorphism support maps to a Win32 DLL or executable into
+ which this generated code is linked. See the \cb{--export-maps}
+ option documentation for details. This options is only valid together
+ with \cb{--generate-polymorphic}. The \cb{XSD_NO_EXPORT} macro can be
+ used to omit this code during C++ compilation, which may be useful if
+ you would like to use the same generated code across multiple
+ platforms."
+ };
+
+ // Make dependency generation.
+ //
+ bool --generate-dep
+ {
+ "Generate \cb{make} dependency information. This option triggers the
+ creation of the \cb{.d} file containing the dependencies of the
+ generated files on the main schema file as well as all the schema
+ files that it includes/imports, transitively. This dependency file
+ is then normally included into the main \cb{makefile} to implement
+ automatic dependency tracking.
+
+ Note also that automatic dependency generation is not supported in
+ the file-per-type mode (\cb{--file-per-type}). In this case, all
+ the generated files are produced with a single compiler invocation
+ and depend on all the schemas. As a result, it is easier to establish
+ such a dependency manually, perhaps with the help of the
+ \cb{--file-list*} options."
+ };
+
+ bool --generate-dep-only
+ {
+ "Generate \cb{make} dependency information only."
+ };
+
+ bool --dep-phony
+ {
+ "Generate phony targets for included/imported schema files, causing
+ each to depend on nothing. Such dummy rules work around \cb{make}
+ errors caused by the removal of schema files without also updating
+ the dependency file to match."
+ };
+
+ NarrowStrings --dep-target
+ {
+ "<target>",
+ "Change the target of the dependency rule. By default it contains
+ all the generated C++ files as well as the dependency file itself,
+ without any directory prefixes. If you require multiple targets,
+ then you can specify them as a single, space-separated argument or
+ you can repeat this option multiple times."
+ };
+
+ NarrowString --dep-suffix = ".d"
+ {
+ "<suffix>",
+ "Use the provided <suffix> instead of the default \cb{.d} to
+ construct the name of the dependency file."
+ };
+
+ NarrowString --dep-regex
+ {
+ "<regex>",
+ "Use the provided expression to construct the name of the dependency
+ file. <regex> is a Perl-like regular expression in the form
+ \c{\b{/}\i{pattern}\b{/}\i{replacement}\b{/}}. See also the REGEX
+ AND SHELL QUOTING section below."
+ };
+ };
+}
diff --git a/xsd/xsd/cxx/options.cxx b/xsd/xsd/cxx/options.cxx
new file mode 100644
index 0000000..1d2e8fd
--- /dev/null
+++ b/xsd/xsd/cxx/options.cxx
@@ -0,0 +1,638 @@
+// This code was generated by CLI, a command line interface
+// compiler for C++.
+//
+
+// Begin prologue.
+//
+#include <options-parser.hxx>
+//
+// End prologue.
+
+#include <cxx/options.hxx>
+
+#include <map>
+#include <set>
+#include <string>
+#include <vector>
+#include <ostream>
+#include <sstream>
+
+namespace cli
+{
+ template <typename X>
+ struct parser
+ {
+ static void
+ parse (X& x, bool& xs, scanner& s)
+ {
+ std::string o (s.next ());
+
+ if (s.more ())
+ {
+ std::string v (s.next ());
+ std::istringstream is (v);
+ if (!(is >> x && is.eof ()))
+ throw invalid_value (o, v);
+ }
+ else
+ throw missing_value (o);
+
+ xs = true;
+ }
+ };
+
+ template <>
+ struct parser<bool>
+ {
+ static void
+ parse (bool& x, scanner& s)
+ {
+ s.next ();
+ x = true;
+ }
+ };
+
+ template <>
+ struct parser<std::string>
+ {
+ static void
+ parse (std::string& x, bool& xs, scanner& s)
+ {
+ const char* o (s.next ());
+
+ if (s.more ())
+ x = s.next ();
+ else
+ throw missing_value (o);
+
+ xs = true;
+ }
+ };
+
+ template <typename X>
+ struct parser<std::vector<X> >
+ {
+ static void
+ parse (std::vector<X>& c, bool& xs, scanner& s)
+ {
+ X x;
+ bool dummy;
+ parser<X>::parse (x, dummy, s);
+ c.push_back (x);
+ xs = true;
+ }
+ };
+
+ template <typename X>
+ struct parser<std::set<X> >
+ {
+ static void
+ parse (std::set<X>& c, bool& xs, scanner& s)
+ {
+ X x;
+ bool dummy;
+ parser<X>::parse (x, dummy, s);
+ c.insert (x);
+ xs = true;
+ }
+ };
+
+ template <typename K, typename V>
+ struct parser<std::map<K, V> >
+ {
+ static void
+ parse (std::map<K, V>& m, bool& xs, scanner& s)
+ {
+ std::string o (s.next ());
+
+ if (s.more ())
+ {
+ std::string ov (s.next ());
+ std::string::size_type p = ov.find ('=');
+
+ if (p == std::string::npos)
+ {
+ K k = K ();
+
+ if (!ov.empty ())
+ {
+ std::istringstream ks (ov);
+
+ if (!(ks >> k && ks.eof ()))
+ throw invalid_value (o, ov);
+ }
+
+ m[k] = V ();
+ }
+ else
+ {
+ K k = K ();
+ V v = V ();
+ std::string kstr (ov, 0, p);
+ std::string vstr (ov, p + 1);
+
+ if (!kstr.empty ())
+ {
+ std::istringstream ks (kstr);
+
+ if (!(ks >> k && ks.eof ()))
+ throw invalid_value (o, ov);
+ }
+
+ if (!vstr.empty ())
+ {
+ std::istringstream vs (vstr);
+
+ if (!(vs >> v && vs.eof ()))
+ throw invalid_value (o, ov);
+ }
+
+ m[k] = v;
+ }
+ }
+ else
+ throw missing_value (o);
+
+ xs = true;
+ }
+ };
+
+ template <typename X, typename T, T X::*M>
+ void
+ thunk (X& x, scanner& s)
+ {
+ parser<T>::parse (x.*M, s);
+ }
+
+ template <typename X, typename T, T X::*M, bool X::*S>
+ void
+ thunk (X& x, scanner& s)
+ {
+ parser<T>::parse (x.*M, x.*S, s);
+ }
+}
+
+#include <map>
+#include <cstring>
+
+namespace CXX
+{
+ // options
+ //
+
+ options::
+ options ()
+ : std_ (cxx_version::cxx98),
+ std_specified_ (false),
+ char_type_ ("char"),
+ char_type_specified_ (false),
+ char_encoding_ (),
+ char_encoding_specified_ (false),
+ output_dir_ (),
+ output_dir_specified_ (false),
+ generate_inline_ (),
+ generate_xml_schema_ (),
+ extern_xml_schema_ (),
+ extern_xml_schema_specified_ (false),
+ namespace_map_ (),
+ namespace_map_specified_ (false),
+ namespace_regex_ (),
+ namespace_regex_specified_ (false),
+ namespace_regex_trace_ (),
+ reserved_name_ (),
+ reserved_name_specified_ (false),
+ include_with_brackets_ (),
+ include_prefix_ (),
+ include_prefix_specified_ (false),
+ include_regex_ (),
+ include_regex_specified_ (false),
+ include_regex_trace_ (),
+ guard_prefix_ (),
+ guard_prefix_specified_ (false),
+ hxx_suffix_ (".hxx"),
+ hxx_suffix_specified_ (false),
+ ixx_suffix_ (".ixx"),
+ ixx_suffix_specified_ (false),
+ cxx_suffix_ (".cxx"),
+ cxx_suffix_specified_ (false),
+ fwd_suffix_ ("-fwd.hxx"),
+ fwd_suffix_specified_ (false),
+ hxx_regex_ (),
+ hxx_regex_specified_ (false),
+ ixx_regex_ (),
+ ixx_regex_specified_ (false),
+ cxx_regex_ (),
+ cxx_regex_specified_ (false),
+ fwd_regex_ (),
+ fwd_regex_specified_ (false),
+ hxx_prologue_ (),
+ hxx_prologue_specified_ (false),
+ ixx_prologue_ (),
+ ixx_prologue_specified_ (false),
+ cxx_prologue_ (),
+ cxx_prologue_specified_ (false),
+ fwd_prologue_ (),
+ fwd_prologue_specified_ (false),
+ prologue_ (),
+ prologue_specified_ (false),
+ hxx_epilogue_ (),
+ hxx_epilogue_specified_ (false),
+ ixx_epilogue_ (),
+ ixx_epilogue_specified_ (false),
+ cxx_epilogue_ (),
+ cxx_epilogue_specified_ (false),
+ fwd_epilogue_ (),
+ fwd_epilogue_specified_ (false),
+ epilogue_ (),
+ epilogue_specified_ (false),
+ hxx_prologue_file_ (),
+ hxx_prologue_file_specified_ (false),
+ ixx_prologue_file_ (),
+ ixx_prologue_file_specified_ (false),
+ cxx_prologue_file_ (),
+ cxx_prologue_file_specified_ (false),
+ fwd_prologue_file_ (),
+ fwd_prologue_file_specified_ (false),
+ prologue_file_ (),
+ prologue_file_specified_ (false),
+ hxx_epilogue_file_ (),
+ hxx_epilogue_file_specified_ (false),
+ ixx_epilogue_file_ (),
+ ixx_epilogue_file_specified_ (false),
+ cxx_epilogue_file_ (),
+ cxx_epilogue_file_specified_ (false),
+ fwd_epilogue_file_ (),
+ fwd_epilogue_file_specified_ (false),
+ epilogue_file_ (),
+ epilogue_file_specified_ (false),
+ export_symbol_ (),
+ export_symbol_specified_ (false),
+ export_xml_schema_ (),
+ export_maps_ (),
+ import_maps_ (),
+ generate_dep_ (),
+ generate_dep_only_ (),
+ dep_phony_ (),
+ dep_target_ (),
+ dep_target_specified_ (false),
+ dep_suffix_ (".d"),
+ dep_suffix_specified_ (false),
+ dep_regex_ (),
+ dep_regex_specified_ (false)
+ {
+ }
+
+ void options::
+ print_usage (::std::wostream& os)
+ {
+ os << "--std <version> Specify the C++ standard that the generated code" << ::std::endl
+ << " should conform to." << ::std::endl;
+
+ os << "--char-type <type> Generate code using the provided character <type>" << ::std::endl
+ << " instead of the default 'char'." << ::std::endl;
+
+ os << "--char-encoding <enc> Specify the character encoding that should be used" << ::std::endl
+ << " in the generated code." << ::std::endl;
+
+ os << "--output-dir <dir> Write generated files to <dir> instead of the" << ::std::endl
+ << " current directory." << ::std::endl;
+
+ os << "--generate-inline Generate simple functions inline." << ::std::endl;
+
+ os << "--generate-xml-schema Generate a C++ header file as if the schema being" << ::std::endl
+ << " compiled defines the XML Schema namespace." << ::std::endl;
+
+ os << "--extern-xml-schema <file> Include a header file derived from <file> instead" << ::std::endl
+ << " of generating the XML Schema namespace mapping" << ::std::endl
+ << " inline." << ::std::endl;
+
+ os << "--namespace-map <xns>=<cns> Map XML Schema namespace <xns> to C++ namespace" << ::std::endl
+ << " <cns>." << ::std::endl;
+
+ os << "--namespace-regex <regex> Add <regex> to the list of regular expressions" << ::std::endl
+ << " used to translate XML Schema namespace names to" << ::std::endl
+ << " C++ namespace names." << ::std::endl;
+
+ os << "--namespace-regex-trace Trace the process of applying regular expressions" << ::std::endl
+ << " specified with the '--namespace-regex' option." << ::std::endl;
+
+ os << "--reserved-name <n>[=<r>] Add name <n> to the list of names that should not" << ::std::endl
+ << " be used as identifiers." << ::std::endl;
+
+ os << "--include-with-brackets Use angle brackets (<>) instead of quotes (\"\") in" << ::std::endl
+ << " generated '#include' directives." << ::std::endl;
+
+ os << "--include-prefix <prefix> Add <prefix> to generated '#include' directive" << ::std::endl
+ << " paths." << ::std::endl;
+
+ os << "--include-regex <regex> Add <regex> to the list of regular expressions" << ::std::endl
+ << " used to transform '#include' directive paths." << ::std::endl;
+
+ os << "--include-regex-trace Trace the process of applying regular expressions" << ::std::endl
+ << " specified with the '--include-regex' option." << ::std::endl;
+
+ os << "--guard-prefix <prefix> Add <prefix> to generated header inclusion guards." << ::std::endl;
+
+ os << "--hxx-suffix <suffix> Use the provided <suffix> instead of the default" << ::std::endl
+ << " '.hxx' to construct the name of the header file." << ::std::endl;
+
+ os << "--ixx-suffix <suffix> Use the provided <suffix> instead of the default" << ::std::endl
+ << " '.ixx' to construct the name of the inline file." << ::std::endl;
+
+ os << "--cxx-suffix <suffix> Use the provided <suffix> instead of the default" << ::std::endl
+ << " '.cxx' to construct the name of the source file." << ::std::endl;
+
+ os << "--fwd-suffix <suffix> Use the provided <suffix> instead of the default" << ::std::endl
+ << " '-fwd.hxx' to construct the name of the forward" << ::std::endl
+ << " declaration file." << ::std::endl;
+
+ os << "--hxx-regex <regex> Use the provided expression to construct the name" << ::std::endl
+ << " of the header file." << ::std::endl;
+
+ os << "--ixx-regex <regex> Use the provided expression to construct the name" << ::std::endl
+ << " of the inline file." << ::std::endl;
+
+ os << "--cxx-regex <regex> Use the provided expression to construct the name" << ::std::endl
+ << " of the source file." << ::std::endl;
+
+ os << "--fwd-regex <regex> Use the provided expression to construct the name" << ::std::endl
+ << " of the forward declaration file." << ::std::endl;
+
+ os << "--hxx-prologue <text> Insert <text> at the beginning of the header file." << ::std::endl;
+
+ os << "--ixx-prologue <text> Insert <text> at the beginning of the inline file." << ::std::endl;
+
+ os << "--cxx-prologue <text> Insert <text> at the beginning of the source file." << ::std::endl;
+
+ os << "--fwd-prologue <text> Insert <text> at the beginning of the forward" << ::std::endl
+ << " declaration file." << ::std::endl;
+
+ os << "--prologue <text> Insert <text> at the beginning of each generated" << ::std::endl
+ << " file for which there is no file-specific prologue." << ::std::endl;
+
+ os << "--hxx-epilogue <text> Insert <text> at the end of the header file." << ::std::endl;
+
+ os << "--ixx-epilogue <text> Insert <text> at the end of the inline file." << ::std::endl;
+
+ os << "--cxx-epilogue <text> Insert <text> at the end of the source file." << ::std::endl;
+
+ os << "--fwd-epilogue <text> Insert <text> at the end of the forward" << ::std::endl
+ << " declaration file." << ::std::endl;
+
+ os << "--epilogue <text> Insert <text> at the end of each generated file" << ::std::endl
+ << " for which there is no file-specific epilogue." << ::std::endl;
+
+ os << "--hxx-prologue-file <file> Insert the content of the <file> at the beginning" << ::std::endl
+ << " of the header file." << ::std::endl;
+
+ os << "--ixx-prologue-file <file> Insert the content of the <file> at the beginning" << ::std::endl
+ << " of the inline file." << ::std::endl;
+
+ os << "--cxx-prologue-file <file> Insert the content of the <file> at the beginning" << ::std::endl
+ << " of the source file." << ::std::endl;
+
+ os << "--fwd-prologue-file <file> Insert the content of the <file> at the beginning" << ::std::endl
+ << " of the forward declaration file." << ::std::endl;
+
+ os << "--prologue-file <file> Insert the content of the <file> at the beginning" << ::std::endl
+ << " of each generated file for which there is no" << ::std::endl
+ << " file-specific prologue file." << ::std::endl;
+
+ os << "--hxx-epilogue-file <file> Insert the content of the <file> at the end of the" << ::std::endl
+ << " header file." << ::std::endl;
+
+ os << "--ixx-epilogue-file <file> Insert the content of the <file> at the end of the" << ::std::endl
+ << " inline file." << ::std::endl;
+
+ os << "--cxx-epilogue-file <file> Insert the content of the <file> at the end of the" << ::std::endl
+ << " source file." << ::std::endl;
+
+ os << "--fwd-epilogue-file <file> Insert the content of the <file> at the end of the" << ::std::endl
+ << " forward declaration file." << ::std::endl;
+
+ os << "--epilogue-file <file> Insert the content of the <file> at the end of" << ::std::endl
+ << " each generated file for which there is no" << ::std::endl
+ << " file-specific epilogue file." << ::std::endl;
+
+ os << "--export-symbol <symbol> Insert <symbol> in places where DLL export/import" << ::std::endl
+ << " control statements" << ::std::endl
+ << " ('__declspec(dllexport/dllimport)') are necessary." << ::std::endl;
+
+ os << "--export-xml-schema Export/import types in the XML Schema namespace" << ::std::endl
+ << " using the export symbol provided with the" << ::std::endl
+ << " '--export-symbol' option." << ::std::endl;
+
+ os << "--export-maps Export polymorphism support maps from a Win32 DLL" << ::std::endl
+ << " into which this generated code is placed." << ::std::endl;
+
+ os << "--import-maps Import polymorphism support maps to a Win32 DLL or" << ::std::endl
+ << " executable into which this generated code is" << ::std::endl
+ << " linked." << ::std::endl;
+
+ os << "--generate-dep Generate 'make' dependency information." << ::std::endl;
+
+ os << "--generate-dep-only Generate 'make' dependency information only." << ::std::endl;
+
+ os << "--dep-phony Generate phony targets for included/imported" << ::std::endl
+ << " schema files, causing each to depend on nothing." << ::std::endl;
+
+ os << "--dep-target <target> Change the target of the dependency rule." << ::std::endl;
+
+ os << "--dep-suffix <suffix> Use the provided <suffix> instead of the default" << ::std::endl
+ << " '.d' to construct the name of the dependency file." << ::std::endl;
+
+ os << "--dep-regex <regex> Use the provided expression to construct the name" << ::std::endl
+ << " of the dependency file." << ::std::endl;
+ }
+
+ typedef
+ std::map<std::string, void (*) (options&, ::cli::scanner&)>
+ _cli_options_map;
+
+ static _cli_options_map _cli_options_map_;
+
+ struct _cli_options_map_init
+ {
+ _cli_options_map_init ()
+ {
+ _cli_options_map_["--std"] =
+ &::cli::thunk< options, cxx_version, &options::std_,
+ &options::std_specified_ >;
+ _cli_options_map_["--char-type"] =
+ &::cli::thunk< options, NarrowString, &options::char_type_,
+ &options::char_type_specified_ >;
+ _cli_options_map_["--char-encoding"] =
+ &::cli::thunk< options, NarrowString, &options::char_encoding_,
+ &options::char_encoding_specified_ >;
+ _cli_options_map_["--output-dir"] =
+ &::cli::thunk< options, NarrowString, &options::output_dir_,
+ &options::output_dir_specified_ >;
+ _cli_options_map_["--generate-inline"] =
+ &::cli::thunk< options, bool, &options::generate_inline_ >;
+ _cli_options_map_["--generate-xml-schema"] =
+ &::cli::thunk< options, bool, &options::generate_xml_schema_ >;
+ _cli_options_map_["--extern-xml-schema"] =
+ &::cli::thunk< options, NarrowString, &options::extern_xml_schema_,
+ &options::extern_xml_schema_specified_ >;
+ _cli_options_map_["--namespace-map"] =
+ &::cli::thunk< options, NarrowStrings, &options::namespace_map_,
+ &options::namespace_map_specified_ >;
+ _cli_options_map_["--namespace-regex"] =
+ &::cli::thunk< options, NarrowStrings, &options::namespace_regex_,
+ &options::namespace_regex_specified_ >;
+ _cli_options_map_["--namespace-regex-trace"] =
+ &::cli::thunk< options, bool, &options::namespace_regex_trace_ >;
+ _cli_options_map_["--reserved-name"] =
+ &::cli::thunk< options, NarrowStrings, &options::reserved_name_,
+ &options::reserved_name_specified_ >;
+ _cli_options_map_["--include-with-brackets"] =
+ &::cli::thunk< options, bool, &options::include_with_brackets_ >;
+ _cli_options_map_["--include-prefix"] =
+ &::cli::thunk< options, NarrowString, &options::include_prefix_,
+ &options::include_prefix_specified_ >;
+ _cli_options_map_["--include-regex"] =
+ &::cli::thunk< options, NarrowStrings, &options::include_regex_,
+ &options::include_regex_specified_ >;
+ _cli_options_map_["--include-regex-trace"] =
+ &::cli::thunk< options, bool, &options::include_regex_trace_ >;
+ _cli_options_map_["--guard-prefix"] =
+ &::cli::thunk< options, NarrowString, &options::guard_prefix_,
+ &options::guard_prefix_specified_ >;
+ _cli_options_map_["--hxx-suffix"] =
+ &::cli::thunk< options, NarrowString, &options::hxx_suffix_,
+ &options::hxx_suffix_specified_ >;
+ _cli_options_map_["--ixx-suffix"] =
+ &::cli::thunk< options, NarrowString, &options::ixx_suffix_,
+ &options::ixx_suffix_specified_ >;
+ _cli_options_map_["--cxx-suffix"] =
+ &::cli::thunk< options, NarrowString, &options::cxx_suffix_,
+ &options::cxx_suffix_specified_ >;
+ _cli_options_map_["--fwd-suffix"] =
+ &::cli::thunk< options, NarrowString, &options::fwd_suffix_,
+ &options::fwd_suffix_specified_ >;
+ _cli_options_map_["--hxx-regex"] =
+ &::cli::thunk< options, NarrowString, &options::hxx_regex_,
+ &options::hxx_regex_specified_ >;
+ _cli_options_map_["--ixx-regex"] =
+ &::cli::thunk< options, NarrowString, &options::ixx_regex_,
+ &options::ixx_regex_specified_ >;
+ _cli_options_map_["--cxx-regex"] =
+ &::cli::thunk< options, NarrowString, &options::cxx_regex_,
+ &options::cxx_regex_specified_ >;
+ _cli_options_map_["--fwd-regex"] =
+ &::cli::thunk< options, NarrowString, &options::fwd_regex_,
+ &options::fwd_regex_specified_ >;
+ _cli_options_map_["--hxx-prologue"] =
+ &::cli::thunk< options, NarrowStrings, &options::hxx_prologue_,
+ &options::hxx_prologue_specified_ >;
+ _cli_options_map_["--ixx-prologue"] =
+ &::cli::thunk< options, NarrowStrings, &options::ixx_prologue_,
+ &options::ixx_prologue_specified_ >;
+ _cli_options_map_["--cxx-prologue"] =
+ &::cli::thunk< options, NarrowStrings, &options::cxx_prologue_,
+ &options::cxx_prologue_specified_ >;
+ _cli_options_map_["--fwd-prologue"] =
+ &::cli::thunk< options, NarrowStrings, &options::fwd_prologue_,
+ &options::fwd_prologue_specified_ >;
+ _cli_options_map_["--prologue"] =
+ &::cli::thunk< options, NarrowStrings, &options::prologue_,
+ &options::prologue_specified_ >;
+ _cli_options_map_["--hxx-epilogue"] =
+ &::cli::thunk< options, NarrowStrings, &options::hxx_epilogue_,
+ &options::hxx_epilogue_specified_ >;
+ _cli_options_map_["--ixx-epilogue"] =
+ &::cli::thunk< options, NarrowStrings, &options::ixx_epilogue_,
+ &options::ixx_epilogue_specified_ >;
+ _cli_options_map_["--cxx-epilogue"] =
+ &::cli::thunk< options, NarrowStrings, &options::cxx_epilogue_,
+ &options::cxx_epilogue_specified_ >;
+ _cli_options_map_["--fwd-epilogue"] =
+ &::cli::thunk< options, NarrowStrings, &options::fwd_epilogue_,
+ &options::fwd_epilogue_specified_ >;
+ _cli_options_map_["--epilogue"] =
+ &::cli::thunk< options, NarrowStrings, &options::epilogue_,
+ &options::epilogue_specified_ >;
+ _cli_options_map_["--hxx-prologue-file"] =
+ &::cli::thunk< options, NarrowString, &options::hxx_prologue_file_,
+ &options::hxx_prologue_file_specified_ >;
+ _cli_options_map_["--ixx-prologue-file"] =
+ &::cli::thunk< options, NarrowString, &options::ixx_prologue_file_,
+ &options::ixx_prologue_file_specified_ >;
+ _cli_options_map_["--cxx-prologue-file"] =
+ &::cli::thunk< options, NarrowString, &options::cxx_prologue_file_,
+ &options::cxx_prologue_file_specified_ >;
+ _cli_options_map_["--fwd-prologue-file"] =
+ &::cli::thunk< options, NarrowString, &options::fwd_prologue_file_,
+ &options::fwd_prologue_file_specified_ >;
+ _cli_options_map_["--prologue-file"] =
+ &::cli::thunk< options, NarrowString, &options::prologue_file_,
+ &options::prologue_file_specified_ >;
+ _cli_options_map_["--hxx-epilogue-file"] =
+ &::cli::thunk< options, NarrowString, &options::hxx_epilogue_file_,
+ &options::hxx_epilogue_file_specified_ >;
+ _cli_options_map_["--ixx-epilogue-file"] =
+ &::cli::thunk< options, NarrowString, &options::ixx_epilogue_file_,
+ &options::ixx_epilogue_file_specified_ >;
+ _cli_options_map_["--cxx-epilogue-file"] =
+ &::cli::thunk< options, NarrowString, &options::cxx_epilogue_file_,
+ &options::cxx_epilogue_file_specified_ >;
+ _cli_options_map_["--fwd-epilogue-file"] =
+ &::cli::thunk< options, NarrowString, &options::fwd_epilogue_file_,
+ &options::fwd_epilogue_file_specified_ >;
+ _cli_options_map_["--epilogue-file"] =
+ &::cli::thunk< options, NarrowString, &options::epilogue_file_,
+ &options::epilogue_file_specified_ >;
+ _cli_options_map_["--export-symbol"] =
+ &::cli::thunk< options, NarrowString, &options::export_symbol_,
+ &options::export_symbol_specified_ >;
+ _cli_options_map_["--export-xml-schema"] =
+ &::cli::thunk< options, bool, &options::export_xml_schema_ >;
+ _cli_options_map_["--export-maps"] =
+ &::cli::thunk< options, bool, &options::export_maps_ >;
+ _cli_options_map_["--import-maps"] =
+ &::cli::thunk< options, bool, &options::import_maps_ >;
+ _cli_options_map_["--generate-dep"] =
+ &::cli::thunk< options, bool, &options::generate_dep_ >;
+ _cli_options_map_["--generate-dep-only"] =
+ &::cli::thunk< options, bool, &options::generate_dep_only_ >;
+ _cli_options_map_["--dep-phony"] =
+ &::cli::thunk< options, bool, &options::dep_phony_ >;
+ _cli_options_map_["--dep-target"] =
+ &::cli::thunk< options, NarrowStrings, &options::dep_target_,
+ &options::dep_target_specified_ >;
+ _cli_options_map_["--dep-suffix"] =
+ &::cli::thunk< options, NarrowString, &options::dep_suffix_,
+ &options::dep_suffix_specified_ >;
+ _cli_options_map_["--dep-regex"] =
+ &::cli::thunk< options, NarrowString, &options::dep_regex_,
+ &options::dep_regex_specified_ >;
+ }
+ };
+
+ static _cli_options_map_init _cli_options_map_init_;
+
+ bool options::
+ _parse (const char* o, ::cli::scanner& s)
+ {
+ _cli_options_map::const_iterator i (_cli_options_map_.find (o));
+
+ if (i != _cli_options_map_.end ())
+ {
+ (*(i->second)) (*this, s);
+ return true;
+ }
+
+ // options base
+ //
+ if (::options::_parse (o, s))
+ return true;
+
+ return false;
+ }
+}
+
+// Begin epilogue.
+//
+//
+// End epilogue.
+
diff --git a/xsd/xsd/cxx/options.hxx b/xsd/xsd/cxx/options.hxx
new file mode 100644
index 0000000..dea93a0
--- /dev/null
+++ b/xsd/xsd/cxx/options.hxx
@@ -0,0 +1,440 @@
+// This code was generated by CLI, a command line interface
+// compiler for C++.
+//
+
+#ifndef CXX_OPTIONS_HXX
+#define CXX_OPTIONS_HXX
+
+// Begin prologue.
+//
+//
+// End prologue.
+
+#include <cstddef>
+
+#include <types.hxx>
+
+#include <cxx/option-types.hxx>
+
+#include <options.hxx>
+
+namespace CXX
+{
+ class options: public ::options
+ {
+ public:
+ // Option accessors.
+ //
+ const cxx_version&
+ std () const;
+
+ bool
+ std_specified () const;
+
+ const NarrowString&
+ char_type () const;
+
+ bool
+ char_type_specified () const;
+
+ const NarrowString&
+ char_encoding () const;
+
+ bool
+ char_encoding_specified () const;
+
+ const NarrowString&
+ output_dir () const;
+
+ bool
+ output_dir_specified () const;
+
+ const bool&
+ generate_inline () const;
+
+ const bool&
+ generate_xml_schema () const;
+
+ const NarrowString&
+ extern_xml_schema () const;
+
+ bool
+ extern_xml_schema_specified () const;
+
+ const NarrowStrings&
+ namespace_map () const;
+
+ bool
+ namespace_map_specified () const;
+
+ const NarrowStrings&
+ namespace_regex () const;
+
+ bool
+ namespace_regex_specified () const;
+
+ const bool&
+ namespace_regex_trace () const;
+
+ const NarrowStrings&
+ reserved_name () const;
+
+ bool
+ reserved_name_specified () const;
+
+ const bool&
+ include_with_brackets () const;
+
+ const NarrowString&
+ include_prefix () const;
+
+ bool
+ include_prefix_specified () const;
+
+ const NarrowStrings&
+ include_regex () const;
+
+ bool
+ include_regex_specified () const;
+
+ const bool&
+ include_regex_trace () const;
+
+ const NarrowString&
+ guard_prefix () const;
+
+ bool
+ guard_prefix_specified () const;
+
+ const NarrowString&
+ hxx_suffix () const;
+
+ bool
+ hxx_suffix_specified () const;
+
+ const NarrowString&
+ ixx_suffix () const;
+
+ bool
+ ixx_suffix_specified () const;
+
+ const NarrowString&
+ cxx_suffix () const;
+
+ bool
+ cxx_suffix_specified () const;
+
+ const NarrowString&
+ fwd_suffix () const;
+
+ bool
+ fwd_suffix_specified () const;
+
+ const NarrowString&
+ hxx_regex () const;
+
+ bool
+ hxx_regex_specified () const;
+
+ const NarrowString&
+ ixx_regex () const;
+
+ bool
+ ixx_regex_specified () const;
+
+ const NarrowString&
+ cxx_regex () const;
+
+ bool
+ cxx_regex_specified () const;
+
+ const NarrowString&
+ fwd_regex () const;
+
+ bool
+ fwd_regex_specified () const;
+
+ const NarrowStrings&
+ hxx_prologue () const;
+
+ bool
+ hxx_prologue_specified () const;
+
+ const NarrowStrings&
+ ixx_prologue () const;
+
+ bool
+ ixx_prologue_specified () const;
+
+ const NarrowStrings&
+ cxx_prologue () const;
+
+ bool
+ cxx_prologue_specified () const;
+
+ const NarrowStrings&
+ fwd_prologue () const;
+
+ bool
+ fwd_prologue_specified () const;
+
+ const NarrowStrings&
+ prologue () const;
+
+ bool
+ prologue_specified () const;
+
+ const NarrowStrings&
+ hxx_epilogue () const;
+
+ bool
+ hxx_epilogue_specified () const;
+
+ const NarrowStrings&
+ ixx_epilogue () const;
+
+ bool
+ ixx_epilogue_specified () const;
+
+ const NarrowStrings&
+ cxx_epilogue () const;
+
+ bool
+ cxx_epilogue_specified () const;
+
+ const NarrowStrings&
+ fwd_epilogue () const;
+
+ bool
+ fwd_epilogue_specified () const;
+
+ const NarrowStrings&
+ epilogue () const;
+
+ bool
+ epilogue_specified () const;
+
+ const NarrowString&
+ hxx_prologue_file () const;
+
+ bool
+ hxx_prologue_file_specified () const;
+
+ const NarrowString&
+ ixx_prologue_file () const;
+
+ bool
+ ixx_prologue_file_specified () const;
+
+ const NarrowString&
+ cxx_prologue_file () const;
+
+ bool
+ cxx_prologue_file_specified () const;
+
+ const NarrowString&
+ fwd_prologue_file () const;
+
+ bool
+ fwd_prologue_file_specified () const;
+
+ const NarrowString&
+ prologue_file () const;
+
+ bool
+ prologue_file_specified () const;
+
+ const NarrowString&
+ hxx_epilogue_file () const;
+
+ bool
+ hxx_epilogue_file_specified () const;
+
+ const NarrowString&
+ ixx_epilogue_file () const;
+
+ bool
+ ixx_epilogue_file_specified () const;
+
+ const NarrowString&
+ cxx_epilogue_file () const;
+
+ bool
+ cxx_epilogue_file_specified () const;
+
+ const NarrowString&
+ fwd_epilogue_file () const;
+
+ bool
+ fwd_epilogue_file_specified () const;
+
+ const NarrowString&
+ epilogue_file () const;
+
+ bool
+ epilogue_file_specified () const;
+
+ const NarrowString&
+ export_symbol () const;
+
+ bool
+ export_symbol_specified () const;
+
+ const bool&
+ export_xml_schema () const;
+
+ const bool&
+ export_maps () const;
+
+ const bool&
+ import_maps () const;
+
+ const bool&
+ generate_dep () const;
+
+ const bool&
+ generate_dep_only () const;
+
+ const bool&
+ dep_phony () const;
+
+ const NarrowStrings&
+ dep_target () const;
+
+ bool
+ dep_target_specified () const;
+
+ const NarrowString&
+ dep_suffix () const;
+
+ bool
+ dep_suffix_specified () const;
+
+ const NarrowString&
+ dep_regex () const;
+
+ bool
+ dep_regex_specified () const;
+
+ // Print usage information.
+ //
+ static void
+ print_usage (::std::wostream&);
+
+ // Implementation details.
+ //
+ protected:
+ options ();
+
+ bool
+ _parse (const char*, ::cli::scanner&);
+
+ public:
+ cxx_version std_;
+ bool std_specified_;
+ NarrowString char_type_;
+ bool char_type_specified_;
+ NarrowString char_encoding_;
+ bool char_encoding_specified_;
+ NarrowString output_dir_;
+ bool output_dir_specified_;
+ bool generate_inline_;
+ bool generate_xml_schema_;
+ NarrowString extern_xml_schema_;
+ bool extern_xml_schema_specified_;
+ NarrowStrings namespace_map_;
+ bool namespace_map_specified_;
+ NarrowStrings namespace_regex_;
+ bool namespace_regex_specified_;
+ bool namespace_regex_trace_;
+ NarrowStrings reserved_name_;
+ bool reserved_name_specified_;
+ bool include_with_brackets_;
+ NarrowString include_prefix_;
+ bool include_prefix_specified_;
+ NarrowStrings include_regex_;
+ bool include_regex_specified_;
+ bool include_regex_trace_;
+ NarrowString guard_prefix_;
+ bool guard_prefix_specified_;
+ NarrowString hxx_suffix_;
+ bool hxx_suffix_specified_;
+ NarrowString ixx_suffix_;
+ bool ixx_suffix_specified_;
+ NarrowString cxx_suffix_;
+ bool cxx_suffix_specified_;
+ NarrowString fwd_suffix_;
+ bool fwd_suffix_specified_;
+ NarrowString hxx_regex_;
+ bool hxx_regex_specified_;
+ NarrowString ixx_regex_;
+ bool ixx_regex_specified_;
+ NarrowString cxx_regex_;
+ bool cxx_regex_specified_;
+ NarrowString fwd_regex_;
+ bool fwd_regex_specified_;
+ NarrowStrings hxx_prologue_;
+ bool hxx_prologue_specified_;
+ NarrowStrings ixx_prologue_;
+ bool ixx_prologue_specified_;
+ NarrowStrings cxx_prologue_;
+ bool cxx_prologue_specified_;
+ NarrowStrings fwd_prologue_;
+ bool fwd_prologue_specified_;
+ NarrowStrings prologue_;
+ bool prologue_specified_;
+ NarrowStrings hxx_epilogue_;
+ bool hxx_epilogue_specified_;
+ NarrowStrings ixx_epilogue_;
+ bool ixx_epilogue_specified_;
+ NarrowStrings cxx_epilogue_;
+ bool cxx_epilogue_specified_;
+ NarrowStrings fwd_epilogue_;
+ bool fwd_epilogue_specified_;
+ NarrowStrings epilogue_;
+ bool epilogue_specified_;
+ NarrowString hxx_prologue_file_;
+ bool hxx_prologue_file_specified_;
+ NarrowString ixx_prologue_file_;
+ bool ixx_prologue_file_specified_;
+ NarrowString cxx_prologue_file_;
+ bool cxx_prologue_file_specified_;
+ NarrowString fwd_prologue_file_;
+ bool fwd_prologue_file_specified_;
+ NarrowString prologue_file_;
+ bool prologue_file_specified_;
+ NarrowString hxx_epilogue_file_;
+ bool hxx_epilogue_file_specified_;
+ NarrowString ixx_epilogue_file_;
+ bool ixx_epilogue_file_specified_;
+ NarrowString cxx_epilogue_file_;
+ bool cxx_epilogue_file_specified_;
+ NarrowString fwd_epilogue_file_;
+ bool fwd_epilogue_file_specified_;
+ NarrowString epilogue_file_;
+ bool epilogue_file_specified_;
+ NarrowString export_symbol_;
+ bool export_symbol_specified_;
+ bool export_xml_schema_;
+ bool export_maps_;
+ bool import_maps_;
+ bool generate_dep_;
+ bool generate_dep_only_;
+ bool dep_phony_;
+ NarrowStrings dep_target_;
+ bool dep_target_specified_;
+ NarrowString dep_suffix_;
+ bool dep_suffix_specified_;
+ NarrowString dep_regex_;
+ bool dep_regex_specified_;
+ };
+}
+
+#include <cxx/options.ixx>
+
+// Begin epilogue.
+//
+//
+// End epilogue.
+
+#endif // CXX_OPTIONS_HXX
diff --git a/xsd/xsd/cxx/options.ixx b/xsd/xsd/cxx/options.ixx
new file mode 100644
index 0000000..0a8cafa
--- /dev/null
+++ b/xsd/xsd/cxx/options.ixx
@@ -0,0 +1,601 @@
+// This code was generated by CLI, a command line interface
+// compiler for C++.
+//
+
+// Begin prologue.
+//
+//
+// End prologue.
+
+namespace CXX
+{
+ // options
+ //
+
+ inline const cxx_version& options::
+ std () const
+ {
+ return this->std_;
+ }
+
+ inline bool options::
+ std_specified () const
+ {
+ return this->std_specified_;
+ }
+
+ inline const NarrowString& options::
+ char_type () const
+ {
+ return this->char_type_;
+ }
+
+ inline bool options::
+ char_type_specified () const
+ {
+ return this->char_type_specified_;
+ }
+
+ inline const NarrowString& options::
+ char_encoding () const
+ {
+ return this->char_encoding_;
+ }
+
+ inline bool options::
+ char_encoding_specified () const
+ {
+ return this->char_encoding_specified_;
+ }
+
+ inline const NarrowString& options::
+ output_dir () const
+ {
+ return this->output_dir_;
+ }
+
+ inline bool options::
+ output_dir_specified () const
+ {
+ return this->output_dir_specified_;
+ }
+
+ inline const bool& options::
+ generate_inline () const
+ {
+ return this->generate_inline_;
+ }
+
+ inline const bool& options::
+ generate_xml_schema () const
+ {
+ return this->generate_xml_schema_;
+ }
+
+ inline const NarrowString& options::
+ extern_xml_schema () const
+ {
+ return this->extern_xml_schema_;
+ }
+
+ inline bool options::
+ extern_xml_schema_specified () const
+ {
+ return this->extern_xml_schema_specified_;
+ }
+
+ inline const NarrowStrings& options::
+ namespace_map () const
+ {
+ return this->namespace_map_;
+ }
+
+ inline bool options::
+ namespace_map_specified () const
+ {
+ return this->namespace_map_specified_;
+ }
+
+ inline const NarrowStrings& options::
+ namespace_regex () const
+ {
+ return this->namespace_regex_;
+ }
+
+ inline bool options::
+ namespace_regex_specified () const
+ {
+ return this->namespace_regex_specified_;
+ }
+
+ inline const bool& options::
+ namespace_regex_trace () const
+ {
+ return this->namespace_regex_trace_;
+ }
+
+ inline const NarrowStrings& options::
+ reserved_name () const
+ {
+ return this->reserved_name_;
+ }
+
+ inline bool options::
+ reserved_name_specified () const
+ {
+ return this->reserved_name_specified_;
+ }
+
+ inline const bool& options::
+ include_with_brackets () const
+ {
+ return this->include_with_brackets_;
+ }
+
+ inline const NarrowString& options::
+ include_prefix () const
+ {
+ return this->include_prefix_;
+ }
+
+ inline bool options::
+ include_prefix_specified () const
+ {
+ return this->include_prefix_specified_;
+ }
+
+ inline const NarrowStrings& options::
+ include_regex () const
+ {
+ return this->include_regex_;
+ }
+
+ inline bool options::
+ include_regex_specified () const
+ {
+ return this->include_regex_specified_;
+ }
+
+ inline const bool& options::
+ include_regex_trace () const
+ {
+ return this->include_regex_trace_;
+ }
+
+ inline const NarrowString& options::
+ guard_prefix () const
+ {
+ return this->guard_prefix_;
+ }
+
+ inline bool options::
+ guard_prefix_specified () const
+ {
+ return this->guard_prefix_specified_;
+ }
+
+ inline const NarrowString& options::
+ hxx_suffix () const
+ {
+ return this->hxx_suffix_;
+ }
+
+ inline bool options::
+ hxx_suffix_specified () const
+ {
+ return this->hxx_suffix_specified_;
+ }
+
+ inline const NarrowString& options::
+ ixx_suffix () const
+ {
+ return this->ixx_suffix_;
+ }
+
+ inline bool options::
+ ixx_suffix_specified () const
+ {
+ return this->ixx_suffix_specified_;
+ }
+
+ inline const NarrowString& options::
+ cxx_suffix () const
+ {
+ return this->cxx_suffix_;
+ }
+
+ inline bool options::
+ cxx_suffix_specified () const
+ {
+ return this->cxx_suffix_specified_;
+ }
+
+ inline const NarrowString& options::
+ fwd_suffix () const
+ {
+ return this->fwd_suffix_;
+ }
+
+ inline bool options::
+ fwd_suffix_specified () const
+ {
+ return this->fwd_suffix_specified_;
+ }
+
+ inline const NarrowString& options::
+ hxx_regex () const
+ {
+ return this->hxx_regex_;
+ }
+
+ inline bool options::
+ hxx_regex_specified () const
+ {
+ return this->hxx_regex_specified_;
+ }
+
+ inline const NarrowString& options::
+ ixx_regex () const
+ {
+ return this->ixx_regex_;
+ }
+
+ inline bool options::
+ ixx_regex_specified () const
+ {
+ return this->ixx_regex_specified_;
+ }
+
+ inline const NarrowString& options::
+ cxx_regex () const
+ {
+ return this->cxx_regex_;
+ }
+
+ inline bool options::
+ cxx_regex_specified () const
+ {
+ return this->cxx_regex_specified_;
+ }
+
+ inline const NarrowString& options::
+ fwd_regex () const
+ {
+ return this->fwd_regex_;
+ }
+
+ inline bool options::
+ fwd_regex_specified () const
+ {
+ return this->fwd_regex_specified_;
+ }
+
+ inline const NarrowStrings& options::
+ hxx_prologue () const
+ {
+ return this->hxx_prologue_;
+ }
+
+ inline bool options::
+ hxx_prologue_specified () const
+ {
+ return this->hxx_prologue_specified_;
+ }
+
+ inline const NarrowStrings& options::
+ ixx_prologue () const
+ {
+ return this->ixx_prologue_;
+ }
+
+ inline bool options::
+ ixx_prologue_specified () const
+ {
+ return this->ixx_prologue_specified_;
+ }
+
+ inline const NarrowStrings& options::
+ cxx_prologue () const
+ {
+ return this->cxx_prologue_;
+ }
+
+ inline bool options::
+ cxx_prologue_specified () const
+ {
+ return this->cxx_prologue_specified_;
+ }
+
+ inline const NarrowStrings& options::
+ fwd_prologue () const
+ {
+ return this->fwd_prologue_;
+ }
+
+ inline bool options::
+ fwd_prologue_specified () const
+ {
+ return this->fwd_prologue_specified_;
+ }
+
+ inline const NarrowStrings& options::
+ prologue () const
+ {
+ return this->prologue_;
+ }
+
+ inline bool options::
+ prologue_specified () const
+ {
+ return this->prologue_specified_;
+ }
+
+ inline const NarrowStrings& options::
+ hxx_epilogue () const
+ {
+ return this->hxx_epilogue_;
+ }
+
+ inline bool options::
+ hxx_epilogue_specified () const
+ {
+ return this->hxx_epilogue_specified_;
+ }
+
+ inline const NarrowStrings& options::
+ ixx_epilogue () const
+ {
+ return this->ixx_epilogue_;
+ }
+
+ inline bool options::
+ ixx_epilogue_specified () const
+ {
+ return this->ixx_epilogue_specified_;
+ }
+
+ inline const NarrowStrings& options::
+ cxx_epilogue () const
+ {
+ return this->cxx_epilogue_;
+ }
+
+ inline bool options::
+ cxx_epilogue_specified () const
+ {
+ return this->cxx_epilogue_specified_;
+ }
+
+ inline const NarrowStrings& options::
+ fwd_epilogue () const
+ {
+ return this->fwd_epilogue_;
+ }
+
+ inline bool options::
+ fwd_epilogue_specified () const
+ {
+ return this->fwd_epilogue_specified_;
+ }
+
+ inline const NarrowStrings& options::
+ epilogue () const
+ {
+ return this->epilogue_;
+ }
+
+ inline bool options::
+ epilogue_specified () const
+ {
+ return this->epilogue_specified_;
+ }
+
+ inline const NarrowString& options::
+ hxx_prologue_file () const
+ {
+ return this->hxx_prologue_file_;
+ }
+
+ inline bool options::
+ hxx_prologue_file_specified () const
+ {
+ return this->hxx_prologue_file_specified_;
+ }
+
+ inline const NarrowString& options::
+ ixx_prologue_file () const
+ {
+ return this->ixx_prologue_file_;
+ }
+
+ inline bool options::
+ ixx_prologue_file_specified () const
+ {
+ return this->ixx_prologue_file_specified_;
+ }
+
+ inline const NarrowString& options::
+ cxx_prologue_file () const
+ {
+ return this->cxx_prologue_file_;
+ }
+
+ inline bool options::
+ cxx_prologue_file_specified () const
+ {
+ return this->cxx_prologue_file_specified_;
+ }
+
+ inline const NarrowString& options::
+ fwd_prologue_file () const
+ {
+ return this->fwd_prologue_file_;
+ }
+
+ inline bool options::
+ fwd_prologue_file_specified () const
+ {
+ return this->fwd_prologue_file_specified_;
+ }
+
+ inline const NarrowString& options::
+ prologue_file () const
+ {
+ return this->prologue_file_;
+ }
+
+ inline bool options::
+ prologue_file_specified () const
+ {
+ return this->prologue_file_specified_;
+ }
+
+ inline const NarrowString& options::
+ hxx_epilogue_file () const
+ {
+ return this->hxx_epilogue_file_;
+ }
+
+ inline bool options::
+ hxx_epilogue_file_specified () const
+ {
+ return this->hxx_epilogue_file_specified_;
+ }
+
+ inline const NarrowString& options::
+ ixx_epilogue_file () const
+ {
+ return this->ixx_epilogue_file_;
+ }
+
+ inline bool options::
+ ixx_epilogue_file_specified () const
+ {
+ return this->ixx_epilogue_file_specified_;
+ }
+
+ inline const NarrowString& options::
+ cxx_epilogue_file () const
+ {
+ return this->cxx_epilogue_file_;
+ }
+
+ inline bool options::
+ cxx_epilogue_file_specified () const
+ {
+ return this->cxx_epilogue_file_specified_;
+ }
+
+ inline const NarrowString& options::
+ fwd_epilogue_file () const
+ {
+ return this->fwd_epilogue_file_;
+ }
+
+ inline bool options::
+ fwd_epilogue_file_specified () const
+ {
+ return this->fwd_epilogue_file_specified_;
+ }
+
+ inline const NarrowString& options::
+ epilogue_file () const
+ {
+ return this->epilogue_file_;
+ }
+
+ inline bool options::
+ epilogue_file_specified () const
+ {
+ return this->epilogue_file_specified_;
+ }
+
+ inline const NarrowString& options::
+ export_symbol () const
+ {
+ return this->export_symbol_;
+ }
+
+ inline bool options::
+ export_symbol_specified () const
+ {
+ return this->export_symbol_specified_;
+ }
+
+ inline const bool& options::
+ export_xml_schema () const
+ {
+ return this->export_xml_schema_;
+ }
+
+ inline const bool& options::
+ export_maps () const
+ {
+ return this->export_maps_;
+ }
+
+ inline const bool& options::
+ import_maps () const
+ {
+ return this->import_maps_;
+ }
+
+ inline const bool& options::
+ generate_dep () const
+ {
+ return this->generate_dep_;
+ }
+
+ inline const bool& options::
+ generate_dep_only () const
+ {
+ return this->generate_dep_only_;
+ }
+
+ inline const bool& options::
+ dep_phony () const
+ {
+ return this->dep_phony_;
+ }
+
+ inline const NarrowStrings& options::
+ dep_target () const
+ {
+ return this->dep_target_;
+ }
+
+ inline bool options::
+ dep_target_specified () const
+ {
+ return this->dep_target_specified_;
+ }
+
+ inline const NarrowString& options::
+ dep_suffix () const
+ {
+ return this->dep_suffix_;
+ }
+
+ inline bool options::
+ dep_suffix_specified () const
+ {
+ return this->dep_suffix_specified_;
+ }
+
+ inline const NarrowString& options::
+ dep_regex () const
+ {
+ return this->dep_regex_;
+ }
+
+ inline bool options::
+ dep_regex_specified () const
+ {
+ return this->dep_regex_specified_;
+ }
+}
+
+// Begin epilogue.
+//
+//
+// End epilogue.
diff --git a/xsd/xsd/cxx/parser/attribute-validation-source.cxx b/xsd/xsd/cxx/parser/attribute-validation-source.cxx
index 536e2da..7ed54e4 100644
--- a/xsd/xsd/cxx/parser/attribute-validation-source.cxx
+++ b/xsd/xsd/cxx/parser/attribute-validation-source.cxx
@@ -1,6 +1,5 @@
// file : xsd/cxx/parser/attribute-validation-source.cxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#include <cxx/parser/attribute-validation-source.hxx>
@@ -23,7 +22,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Attribute& a)
{
String const& name (a.name ());
@@ -39,7 +38,7 @@ namespace CXX
os << "n == " << strlit (name) << " && ns.empty ()";
}
- virtual Void
+ virtual void
traverse (SemanticGraph::AnyAttribute& a)
{
String const& ns (a.definition_namespace ().name ());
@@ -93,7 +92,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& a)
{
String const& name (ename (a));
@@ -120,10 +119,20 @@ namespace CXX
os << "this->" << inst << "->" << post << " ();"
<< "this->" << name << " ();";
else
- os << arg_type (type) << " tmp (this->" << inst << "->" <<
- post << " ());"
- << "this->" << name << " (tmp);"
- << endl;
+ {
+ // Don't create an lvalue in C++11 (think std::unique_ptr).
+ // In C++98 we do it for compatibility with older/broken
+ // compilers (e.g., IBM xlC that needs an lvalue to pass
+ // std::auto_ptr).
+ //
+ if (std == cxx_version::cxx98)
+ os << arg_type (type) << " tmp (this->" << inst << "->" <<
+ post << " ());"
+ << "this->" << name << " (tmp);";
+ else
+ os << "this->" << name << " (this->" << inst << "->" <<
+ post << " ());";
+ }
os << "}";
@@ -149,7 +158,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& a)
{
os << "if (";
@@ -177,7 +186,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& a)
{
if (!a.optional_p ())
@@ -195,7 +204,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& a)
{
if (!a.optional_p ())
@@ -227,16 +236,16 @@ namespace CXX
names_attribute_state_check_ >> attribute_state_check_;
}
- virtual Void
+ virtual void
traverse (Type& c)
{
- Boolean has_att (has<Traversal::Attribute> (c));
- Boolean has_any (has<Traversal::AnyAttribute> (c));
+ bool has_att (has<Traversal::Attribute> (c));
+ bool has_any (has<Traversal::AnyAttribute> (c));
if (!has_att && !has_any)
return;
- Boolean has_req_att (false);
+ bool has_req_att (false);
if (has_att)
{
RequiredAttributeTest test (has_req_att);
@@ -380,12 +389,12 @@ namespace CXX
};
}
- Void
+ void
generate_attribute_validation_source (Context& ctx)
{
Traversal::Schema schema;
- Traversal::Sources sources;
+ Sources sources;
Traversal::Names schema_names;
Namespace ns (ctx);
diff --git a/xsd/xsd/cxx/parser/attribute-validation-source.hxx b/xsd/xsd/cxx/parser/attribute-validation-source.hxx
index a11f434..10438fd 100644
--- a/xsd/xsd/cxx/parser/attribute-validation-source.hxx
+++ b/xsd/xsd/cxx/parser/attribute-validation-source.hxx
@@ -1,6 +1,5 @@
// file : xsd/cxx/parser/attribute-validation-source.hxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#ifndef CXX_PARSER_ATTRIBUTE_VALIDATION_SOURCE_HXX
@@ -12,7 +11,7 @@ namespace CXX
{
namespace Parser
{
- Void
+ void
generate_attribute_validation_source (Context&);
}
}
diff --git a/xsd/xsd/cxx/parser/characters-validation-source.cxx b/xsd/xsd/cxx/parser/characters-validation-source.cxx
index 236f2f5..ddecc70 100644
--- a/xsd/xsd/cxx/parser/characters-validation-source.cxx
+++ b/xsd/xsd/cxx/parser/characters-validation-source.cxx
@@ -1,6 +1,5 @@
// file : xsd/cxx/parser/characters-validation-source.cxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#include <cxx/parser/characters-validation-source.hxx>
@@ -23,7 +22,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& c)
{
if (!c.mixed_p ())
@@ -46,7 +45,7 @@ namespace CXX
};
}
- Void
+ void
generate_characters_validation_source (Context& ctx)
{
//@@ Most of the time there is no mixed content type so
@@ -56,7 +55,7 @@ namespace CXX
//
Traversal::Schema schema;
- Traversal::Sources sources;
+ Sources sources;
Traversal::Names schema_names;
Namespace ns (ctx);
diff --git a/xsd/xsd/cxx/parser/characters-validation-source.hxx b/xsd/xsd/cxx/parser/characters-validation-source.hxx
index 2c1a1b1..219df3e 100644
--- a/xsd/xsd/cxx/parser/characters-validation-source.hxx
+++ b/xsd/xsd/cxx/parser/characters-validation-source.hxx
@@ -1,6 +1,5 @@
// file : xsd/cxx/parser/characters-validation-source.hxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#ifndef CXX_PARSER_CHARACTERS_VALIDATION_SOURCE_HXX
@@ -12,7 +11,7 @@ namespace CXX
{
namespace Parser
{
- Void
+ void
generate_characters_validation_source (Context&);
}
}
diff --git a/xsd/xsd/cxx/parser/cli.hxx b/xsd/xsd/cxx/parser/cli.hxx
deleted file mode 100644
index bc7ca1a..0000000
--- a/xsd/xsd/cxx/parser/cli.hxx
+++ /dev/null
@@ -1,154 +0,0 @@
-// file : xsd/cxx/parser/cli.hxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
-// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
-
-#ifndef CXX_PARSER_CLI_HXX
-#define CXX_PARSER_CLI_HXX
-
-#include <cult/types.hxx>
-
-#include <cult/containers/vector.hxx>
-
-#include <cult/cli/options.hxx>
-#include <cult/cli/options-spec.hxx>
-
-namespace CXX
-{
- namespace Parser
- {
- namespace CLI
- {
- using namespace Cult::Types;
-
- typedef Char const Key[];
-
- extern Key type_map;
- extern Key char_encoding;
- extern Key char_type;
- extern Key output_dir;
- extern Key xml_parser;
- extern Key generate_inline;
- extern Key generate_validation;
- extern Key suppress_validation;
- extern Key generate_polymorphic;
- extern Key generate_noop_impl;
- extern Key generate_print_impl;
- extern Key generate_test_driver;
- extern Key force_overwrite;
- extern Key root_element_first;
- extern Key root_element_last;
- extern Key root_element;
- extern Key generate_xml_schema;
- extern Key extern_xml_schema;
- extern Key skel_type_suffix;
- extern Key skel_file_suffix;
- extern Key impl_type_suffix;
- extern Key impl_file_suffix;
- extern Key namespace_map;
- extern Key namespace_regex;
- extern Key namespace_regex_trace;
- extern Key reserved_name;
- extern Key include_with_brackets;
- extern Key include_prefix;
- extern Key include_regex;
- extern Key include_regex_trace;
- extern Key guard_prefix;
- extern Key hxx_suffix;
- extern Key ixx_suffix;
- extern Key cxx_suffix;
- extern Key hxx_regex;
- extern Key ixx_regex;
- extern Key cxx_regex;
- extern Key hxx_prologue;
- extern Key ixx_prologue;
- extern Key cxx_prologue;
- extern Key prologue;
- extern Key hxx_epilogue;
- extern Key ixx_epilogue;
- extern Key cxx_epilogue;
- extern Key epilogue;
- extern Key hxx_prologue_file;
- extern Key ixx_prologue_file;
- extern Key cxx_prologue_file;
- extern Key prologue_file;
- extern Key hxx_epilogue_file;
- extern Key ixx_epilogue_file;
- extern Key cxx_epilogue_file;
- extern Key epilogue_file;
- extern Key export_symbol;
- extern Key export_maps;
- extern Key import_maps;
- extern Key show_anonymous;
- extern Key show_sloc;
- extern Key proprietary_license;
-
- typedef Cult::CLI::Options<
- type_map, Cult::Containers::Vector<NarrowString>,
- char_type, NarrowString,
- char_encoding, NarrowString,
- output_dir, NarrowString,
- xml_parser, NarrowString,
- generate_inline, Boolean,
- generate_validation, Boolean,
- suppress_validation, Boolean,
- generate_polymorphic, Boolean,
- generate_noop_impl, Boolean,
- generate_print_impl, Boolean,
- generate_test_driver, Boolean,
- force_overwrite, Boolean,
- root_element_first, Boolean,
- root_element_last, Boolean,
- root_element, NarrowString,
- generate_xml_schema, Boolean,
- extern_xml_schema, NarrowString,
- skel_type_suffix, NarrowString,
- skel_file_suffix, NarrowString,
- impl_type_suffix, NarrowString,
- impl_file_suffix, NarrowString,
- namespace_map, Cult::Containers::Vector<NarrowString>,
- namespace_regex, Cult::Containers::Vector<NarrowString>,
- namespace_regex_trace, Boolean,
- reserved_name, Cult::Containers::Vector<NarrowString>,
- include_with_brackets, Boolean,
- include_prefix, NarrowString,
- include_regex, Cult::Containers::Vector<NarrowString>,
- include_regex_trace, Boolean,
- guard_prefix, NarrowString,
- hxx_suffix, NarrowString,
- ixx_suffix, NarrowString,
- cxx_suffix, NarrowString,
- hxx_regex, NarrowString,
- ixx_regex, NarrowString,
- cxx_regex, NarrowString,
- hxx_prologue, Cult::Containers::Vector<NarrowString>,
- ixx_prologue, Cult::Containers::Vector<NarrowString>,
- cxx_prologue, Cult::Containers::Vector<NarrowString>,
- prologue, Cult::Containers::Vector<NarrowString>,
- hxx_epilogue, Cult::Containers::Vector<NarrowString>,
- ixx_epilogue, Cult::Containers::Vector<NarrowString>,
- cxx_epilogue, Cult::Containers::Vector<NarrowString>,
- epilogue, Cult::Containers::Vector<NarrowString>,
- hxx_prologue_file, NarrowString,
- ixx_prologue_file, NarrowString,
- cxx_prologue_file, NarrowString,
- prologue_file, NarrowString,
- hxx_epilogue_file, NarrowString,
- ixx_epilogue_file, NarrowString,
- cxx_epilogue_file, NarrowString,
- epilogue_file, NarrowString,
- export_symbol, NarrowString,
- export_maps, Boolean,
- import_maps, Boolean,
- show_anonymous, Boolean,
- show_sloc, Boolean,
- proprietary_license, Boolean
-
- > Options;
-
- struct OptionsSpec: Cult::CLI::OptionsSpec<Options> {};
- }
- }
-}
-
-#endif // CXX_PARSER_CLI_HXX
diff --git a/xsd/xsd/cxx/parser/driver-source.cxx b/xsd/xsd/cxx/parser/driver-source.cxx
index b48b0e0..510c965 100644
--- a/xsd/xsd/cxx/parser/driver-source.cxx
+++ b/xsd/xsd/cxx/parser/driver-source.cxx
@@ -1,18 +1,18 @@
// file : xsd/cxx/parser/driver-source.cxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+#include <set>
+#include <map>
+#include <sstream>
+
#include <cxx/parser/driver-source.hxx>
#include <cxx/parser/print-impl-common.hxx>
#include <xsd-frontend/semantic-graph.hxx>
#include <xsd-frontend/traversal.hxx>
-#include <cult/containers/map.hxx>
-#include <cult/containers/set.hxx>
-
-#include <sstream>
+using namespace std;
namespace CXX
{
@@ -20,23 +20,22 @@ namespace CXX
{
namespace
{
- typedef
- Cult::Containers::Map<SemanticGraph::Type*, String>
- TypeInstanceMap;
-
- typedef Cult::Containers::Set<String> InstanceSet;
+ typedef map<SemanticGraph::Type*, String> TypeInstanceMap;
+ typedef set<String> InstanceSet;
// For base types we only want member's types, but not the
// base itself.
//
- struct BaseType: Traversal::Complex, Context
+ struct BaseType: Traversal::Complex,
+ Traversal::List,
+ Context
{
- BaseType (Context& c)
- : Context (c)
+ BaseType (Context& c, Traversal::NodeBase& def)
+ : Context (c), def_ (def)
{
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Complex& c)
{
inherits (c);
@@ -44,6 +43,15 @@ namespace CXX
if (!restriction_p (c))
names (c);
}
+
+ virtual void
+ traverse (SemanticGraph::List& l)
+ {
+ def_.dispatch (l.argumented ().type ());
+ }
+
+ private:
+ Traversal::NodeBase& def_;
};
struct ParserDef: Traversal::Type,
@@ -109,7 +117,7 @@ namespace CXX
Context
{
ParserDef (Context& c, TypeInstanceMap& map, InstanceSet& set)
- : Context (c), map_ (map), set_ (set), base_ (c)
+ : Context (c), map_ (map), set_ (set), base_ (c, *this)
{
*this >> inherits_ >> base_ >> inherits_;
@@ -119,7 +127,7 @@ namespace CXX
names_ >> member_ >> belongs_ >> *this;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Type& t)
{
if (map_.find (&t) == map_.end ())
@@ -131,7 +139,7 @@ namespace CXX
}
}
- virtual Void
+ virtual void
traverse (SemanticGraph::List& l)
{
if (map_.find (&l) == map_.end ())
@@ -145,7 +153,7 @@ namespace CXX
}
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Complex& c)
{
if (map_.find (&c) == map_.end ())
@@ -164,13 +172,13 @@ namespace CXX
// anyType & anySimpleType.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::AnyType& t)
{
fund_type (t, "any_type");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::AnySimpleType& t)
{
fund_type (t, "any_simple_type");
@@ -178,7 +186,7 @@ namespace CXX
// Boolean.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Boolean& t)
{
fund_type (t, "boolean");
@@ -186,79 +194,79 @@ namespace CXX
// Integral types.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Byte& t)
{
fund_type (t, "byte");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::UnsignedByte& t)
{
fund_type (t, "unsigned_byte");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Short& t)
{
fund_type (t, "short");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::UnsignedShort& t)
{
fund_type (t, "unsigned_short");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Int& t)
{
fund_type (t, "int");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::UnsignedInt& t)
{
fund_type (t, "unsigned_int");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Long& t)
{
fund_type (t, "long");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::UnsignedLong& t)
{
fund_type (t, "unsigned_long");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Integer& t)
{
fund_type (t, "integer");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NonPositiveInteger& t)
{
fund_type (t, "non_positive_integer");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NonNegativeInteger& t)
{
fund_type (t, "non_negative_integer");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::PositiveInteger& t)
{
fund_type (t, "positive_integer");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NegativeInteger& t)
{
fund_type (t, "negative_integer");
@@ -266,19 +274,19 @@ namespace CXX
// Floats.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Float& t)
{
fund_type (t, "float");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Double& t)
{
fund_type (t, "double");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Decimal& t)
{
fund_type (t, "decimal");
@@ -286,49 +294,49 @@ namespace CXX
// Strings.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::String& t)
{
fund_type (t, "string");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NormalizedString& t)
{
fund_type (t, "normalized_string");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Token& t)
{
fund_type (t, "token");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NameToken& t)
{
fund_type (t, "nmtoken");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NameTokens& t)
{
fund_type (t, "nmtokens");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Name& t)
{
fund_type (t, "name");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NCName& t)
{
fund_type (t, "ncname");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Language& t)
{
fund_type (t, "language");
@@ -337,7 +345,7 @@ namespace CXX
// Qualified name.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::QName& t)
{
fund_type (t, "qname");
@@ -346,19 +354,19 @@ namespace CXX
// ID/IDREF.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Id& t)
{
fund_type (t, "id");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::IdRef& t)
{
fund_type (t, "idref");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::IdRefs& t)
{
fund_type (t, "idrefs");
@@ -366,7 +374,7 @@ namespace CXX
// URI.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::AnyURI& t)
{
fund_type (t, "uri");
@@ -374,13 +382,13 @@ namespace CXX
// Binary.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Base64Binary& t)
{
fund_type (t, "base64_binary");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::HexBinary& t)
{
fund_type (t, "hex_binary");
@@ -389,55 +397,55 @@ namespace CXX
// Date/time.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Date& t)
{
fund_type (t, "date");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::DateTime& t)
{
fund_type (t, "date_time");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Duration& t)
{
fund_type (t, "duration");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Day& t)
{
fund_type (t, "day");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Month& t)
{
fund_type (t, "month");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::MonthDay& t)
{
fund_type (t, "month_day");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Year& t)
{
fund_type (t, "year");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::YearMonth& t)
{
fund_type (t, "year_month");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Time& t)
{
fund_type (t, "time");
@@ -445,20 +453,20 @@ namespace CXX
// Entity.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Entity& t)
{
fund_type (t, "entity");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Entities& t)
{
fund_type (t, "entities");
}
private:
- virtual Void
+ virtual void
fund_type (SemanticGraph::Type& t, String const& name)
{
if (map_.find (&t) == map_.end ())
@@ -476,7 +484,7 @@ namespace CXX
String base_name (escape (raw_name + L"_p"));
String name (base_name);
- for (UnsignedLong i (1); set_.find (name) != set_.end (); ++i)
+ for (size_t i (1); set_.find (name) != set_.end (); ++i)
{
std::wostringstream os;
os << i;
@@ -516,7 +524,7 @@ namespace CXX
names_ >> *this;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Complex& c)
{
inherits (c, inherits_);
@@ -525,7 +533,7 @@ namespace CXX
names (c, names_);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::List& l)
{
if (!first_)
@@ -536,7 +544,7 @@ namespace CXX
os << map_[&l.argumented ().type ()];
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Member& m)
{
if (skip (m))
@@ -556,7 +564,7 @@ namespace CXX
Traversal::Inherits inherits_;
Traversal::Names names_;
- Boolean first_;
+ bool first_;
};
struct ParserConnect: Traversal::List,
@@ -564,7 +572,7 @@ namespace CXX
Context
{
ParserConnect (Context& c, TypeInstanceMap& map)
- : Context (c), map_ (map), base_ (c)
+ : Context (c), map_ (map), base_ (c, *this)
{
*this >> inherits_ >> base_ >> inherits_;
@@ -574,7 +582,7 @@ namespace CXX
names_ >> member_ >> belongs_ >> *this;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::List& l)
{
if (type_set_.find (&l) == type_set_.end ())
@@ -587,7 +595,7 @@ namespace CXX
}
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Complex& c)
{
if (type_set_.find (&c) == type_set_.end ())
@@ -613,7 +621,7 @@ namespace CXX
}
private:
- Boolean
+ bool
has_members (SemanticGraph::Complex& c)
{
using SemanticGraph::Complex;
@@ -636,7 +644,7 @@ namespace CXX
private:
TypeInstanceMap& map_;
- Cult::Containers::Set<SemanticGraph::Type*> type_set_;
+ set<SemanticGraph::Type*> type_set_;
BaseType base_;
Traversal::Inherits inherits_;
@@ -647,7 +655,7 @@ namespace CXX
};
}
- Void
+ void
generate_driver_source (Context& ctx)
{
// Figure out the root element. Validator should have made sure
@@ -656,7 +664,7 @@ namespace CXX
SemanticGraph::Element* root (0);
{
Traversal::Schema schema;
- Traversal::Sources sources;
+ Sources sources;
schema >> sources >> schema;
@@ -740,7 +748,7 @@ namespace CXX
root_p << "." << post << " ());"
<< endl;
- if (ctx.options.value<CLI::generate_print_impl> ())
+ if (ctx.options.generate_print_impl ())
{
PrintCall t (ctx, root->name (), "v");
t.dispatch (root_type);
diff --git a/xsd/xsd/cxx/parser/driver-source.hxx b/xsd/xsd/cxx/parser/driver-source.hxx
index 9b5a8b1..53e19d8 100644
--- a/xsd/xsd/cxx/parser/driver-source.hxx
+++ b/xsd/xsd/cxx/parser/driver-source.hxx
@@ -1,6 +1,5 @@
// file : xsd/cxx/parser/driver-source.hxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#ifndef CXX_PARSER_DRIVER_SOURCE_HXX
@@ -12,7 +11,7 @@ namespace CXX
{
namespace Parser
{
- Void
+ void
generate_driver_source (Context&);
}
}
diff --git a/xsd/xsd/cxx/parser/element-validation-source.cxx b/xsd/xsd/cxx/parser/element-validation-source.cxx
index 211a0d3..b2c244e 100644
--- a/xsd/xsd/cxx/parser/element-validation-source.cxx
+++ b/xsd/xsd/cxx/parser/element-validation-source.cxx
@@ -1,14 +1,15 @@
// file : xsd/cxx/parser/element-validation-source.cxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+#include <vector>
+
#include <cxx/parser/element-validation-source.hxx>
#include <xsd-frontend/semantic-graph.hxx>
#include <xsd-frontend/traversal.hxx>
-#include <cult/containers/vector.hxx>
+using namespace std;
namespace CXX
{
@@ -16,8 +17,7 @@ namespace CXX
{
namespace
{
- typedef Cult::Containers::Vector<SemanticGraph::Particle*> Particles;
-
+ typedef vector<SemanticGraph::Particle*> Particles;
//
//
@@ -31,7 +31,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Element& e)
{
String const& name (e.name ());
@@ -62,7 +62,7 @@ namespace CXX
}
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Any& a)
{
String const& ns (a.definition_namespace ().name ());
@@ -109,7 +109,7 @@ namespace CXX
}
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Compositor& c)
{
// This compositor should already have been tested for
@@ -117,9 +117,9 @@ namespace CXX
//
Particles const& p (c.context ().get<Particles> ("prefixes"));
- Boolean paren (p.size () != 1);
+ bool paren (p.size () != 1);
- for (Particles::ConstIterator i (p.begin ()), e (p.end ());
+ for (Particles::const_iterator i (p.begin ()), e (p.end ());
i != e;)
{
if (paren)
@@ -150,21 +150,21 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Element& e)
{
String ns (e.qualified_p () ? e.namespace_ ().name () : String ());
os << strlit (ns) << ", " << strlit (e.name ());
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Any& a)
{
String const& ns (*a.namespace_begin ());
os << strlit (ns) << ", " << L << "\"*\"";
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Compositor& c)
{
Particles const& p (c.context ().get<Particles> ("prefixes"));
@@ -187,7 +187,7 @@ namespace CXX
// Generate sub-parser setup code as well as the pre/post calls.
//
- Void
+ void
pre_post_calls (SemanticGraph::Particle& p)
{
using SemanticGraph::Element;
@@ -196,20 +196,23 @@ namespace CXX
if (Element* e = dynamic_cast<Element*> (&p))
{
SemanticGraph::Type& type (e->type ());
- Boolean poly (polymorphic && !anonymous (type));
+ String const& fq_type (fq_name (type));
+ bool poly (polymorphic && !anonymous (type));
String name, inst, def_parser, map;
if (e->context ().count("name"))
{
name = ename (*e);
- inst = poly ? emember_cache (*e) : emember (*e);
if (poly)
{
def_parser = emember (*e);
map = emember_map (*e);
+ inst = "p";
}
+ else
+ inst = L"this->" + emember (*e);
}
else
{
@@ -222,13 +225,15 @@ namespace CXX
Element& fe (dynamic_cast<Element&>(ip.first->named ()));
name = ename (fe);
- inst = poly ? emember_cache (fe) : emember (fe);
if (poly)
{
def_parser = emember (fe);
map = emember_map (fe);
+ inst = "p";
}
+ else
+ inst = L"this->" + emember (fe);
}
if (poly)
@@ -243,8 +248,10 @@ namespace CXX
type_id += type_ns;
}
- os << "if (t == 0 && this->" << def_parser << " != 0)" << endl
- << "this->" << inst << " = this->" << def_parser << ";"
+ os << fq_type << "* p = 0;"
+ << endl
+ << "if (t == 0 && this->" << def_parser << " != 0)" << endl
+ << inst << " = this->" << def_parser << ";"
<< "else"
<< "{"
<< string_type << " ts (" << fq_name (type) <<
@@ -254,7 +261,7 @@ namespace CXX
<< "t = &ts;"
<< endl
<< "if (this->" << def_parser << " != 0 && *t == ts)" << endl
- << "this->" << inst << " = this->" << def_parser << ";"
+ << inst << " = this->" << def_parser << ";"
<< "else"
<< "{";
@@ -269,36 +276,51 @@ namespace CXX
" > (*t);"
<< endl
<< "if (this->" << map << " != 0)" << endl
- << "this->" << inst << " = dynamic_cast< " <<
- fq_name (type) << "* > (" << endl
+ << inst << " = dynamic_cast< " << fq_type << "* > (" << endl
<< "this->" << map << "->find (*t));"
- << "else" << endl
- << "this->" << inst << " = 0;"
<< "}"
<< "}";
}
os << "this->" << complex_base << "::context_.top ()." <<
- "parser_ = this->" << inst << ";"
+ "parser_ = " << inst << ";"
<< endl
- << "if (this->" << inst << ")" << endl
- << "this->" << inst << "->pre ();"
+ << "if (" << inst << ")" << endl
+ << inst << "->pre ();"
<< "}"
<< "else" // start
- << "{"
- << "if (this->" << inst << ")"
+ << "{";
+
+ if (poly)
+ os << fq_type << "* p =" << endl
+ << "dynamic_cast< " << fq_type << "* > (" << endl
+ << "this->" << complex_base << "::context_.top ().parser_);"
+ << endl;
+
+ os << "if (" << inst << ")"
<< "{";
String const& ret (ret_type (type));
String const& post (post_name (type));
if (ret == L"void")
- os << "this->" << inst << "->" << post << " ();"
+ os << inst << "->" << post << " ();"
<< "this->" << name << " ();";
else
- os << arg_type (type) << " tmp (this->" << inst << "->" <<
- post << " ());"
- << "this->" << name << " (tmp);";
+ {
+ // Don't create an lvalue in C++11 (think std::unique_ptr).
+ // In C++98 we do it for compatibility with older/broken
+ // compilers (e.g., IBM xlC that needs an lvalue to pass
+ // std::auto_ptr).
+ //
+ if (std == cxx_version::cxx98)
+ os << arg_type (type) << " tmp (" << inst << "->" <<
+ post << " ());"
+ << "this->" << name << " (tmp);";
+ else
+ os << "this->" << name << " (" << inst << "->" <<
+ post << " ());";
+ }
os << "}";
}
@@ -331,10 +353,10 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Element& e)
{
- UnsignedLong state (e.context ().get<UnsignedLong> ("state"));
+ size_t state (e.context ().get<size_t> ("state"));
if (state != 0)
os << "else ";
@@ -382,14 +404,14 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Particle& p)
{
using SemanticGraph::Element;
- UnsignedLong state (p.context ().get<UnsignedLong> ("state"));
+ size_t state (p.context ().get<size_t> ("state"));
- UnsignedLong min (p.min ()), max (p.max ());
+ size_t min (p.min ()), max (p.max ());
os << "case " << state << "UL:" << endl
<< "{";
@@ -465,15 +487,15 @@ namespace CXX
<< "}"; // case
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Compositor& c)
{
using SemanticGraph::Compositor;
- UnsignedLong max (c.max ());
- UnsignedLong min (c.context ().get<UnsignedLong> ("effective-min"));
- UnsignedLong n (c.context ().get<UnsignedLong> ("comp-number"));
- UnsignedLong state (c.context ().get<UnsignedLong> ("state"));
+ size_t max (c.max ());
+ size_t min (c.context ().get<size_t> ("effective-min"));
+ size_t n (c.context ().get<size_t> ("comp-number"));
+ size_t state (c.context ().get<size_t> ("state"));
String func (c.is_a<SemanticGraph::Choice> () ?
"choice_" : "sequence_");
@@ -483,7 +505,7 @@ namespace CXX
<< "unsigned long s (~0UL);"
<< endl;
- Boolean first (true);
+ bool first (true);
for (Compositor::ContainsIterator ci (c.contains_begin ());
ci != c.contains_end (); ++ci)
@@ -496,7 +518,7 @@ namespace CXX
if (!p.context ().count ("prefix"))
break;
- UnsignedLong state (p.context ().get<UnsignedLong> ("state"));
+ size_t state (p.context ().get<size_t> ("state"));
if (first)
first = false;
@@ -599,8 +621,8 @@ namespace CXX
ParticleInCompositor
{
ParticleInSequence (Context& c,
- UnsignedLong state,
- UnsignedLong next_state,
+ size_t state,
+ size_t next_state,
SemanticGraph::Complex& type)
: ParticleInCompositor (c, type),
state_ (state), particle_name_ (c)
@@ -617,10 +639,10 @@ namespace CXX
next_state_ = L"~0";
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Particle& p)
{
- UnsignedLong min (p.min ()), max (p.max ());
+ size_t min (p.min ()), max (p.max ());
os << "case " << state_ << "UL:" << endl
<< "{"
@@ -694,14 +716,14 @@ namespace CXX
<< "}"; // case
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Compositor& c)
{
using SemanticGraph::Compositor;
- UnsignedLong max (c.max ());
- UnsignedLong min (c.context ().get<UnsignedLong> ("effective-min"));
- UnsignedLong n (c.context ().get<UnsignedLong> ("comp-number"));
+ size_t max (c.max ());
+ size_t min (c.context ().get<size_t> ("effective-min"));
+ size_t n (c.context ().get<size_t> ("comp-number"));
String func (c.is_a<SemanticGraph::Choice> () ?
"choice_" : "sequence_");
@@ -711,7 +733,7 @@ namespace CXX
<< "unsigned long s (~0UL);"
<< endl;
- Boolean first (true);
+ bool first (true);
for (Compositor::ContainsIterator ci (c.contains_begin ());
ci != c.contains_end (); ++ci)
@@ -724,7 +746,7 @@ namespace CXX
if (!p.context ().count ("prefix"))
break;
- UnsignedLong state (p.context ().get<UnsignedLong> ("state"));
+ size_t state (p.context ().get<size_t> ("state"));
if (first)
first = false;
@@ -816,7 +838,7 @@ namespace CXX
}
private:
- UnsignedLong state_;
+ size_t state_;
String next_state_;
ParticleName particle_name_;
@@ -837,7 +859,7 @@ namespace CXX
}
- virtual Void
+ virtual void
traverse (SemanticGraph::All& a)
{
if (!a.context().count ("comp-number")) // Empty compositor.
@@ -878,7 +900,7 @@ namespace CXX
Element& e (dynamic_cast<Element&> (ci->particle ()));
String ns (e.qualified_p () ? e.namespace_ ().name () : String ());
- UnsignedLong state (e.context ().get<UnsignedLong> ("state"));
+ size_t state (e.context ().get<size_t> ("state"));
os << "if (count[" << state << "UL] == 0)" << endl
<< "this->_expected_element (" << endl
@@ -894,7 +916,7 @@ namespace CXX
<< "}";
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Choice& c)
{
if (!c.context().count ("comp-number")) // Empty compositor.
@@ -902,7 +924,7 @@ namespace CXX
using SemanticGraph::Compositor;
- UnsignedLong n (c.context ().get<UnsignedLong> ("comp-number"));
+ size_t n (c.context ().get<size_t> ("comp-number"));
os << "void " << ename (type_) << "::" << endl
<< "choice_" << n << " (unsigned long& state," << endl
@@ -940,7 +962,7 @@ namespace CXX
Traversal::Choice::traverse (c);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Sequence& s)
{
if (!s.context().count ("comp-number")) // Empty compositor.
@@ -948,7 +970,7 @@ namespace CXX
using SemanticGraph::Compositor;
- UnsignedLong n (s.context ().get<UnsignedLong> ("comp-number"));
+ size_t n (s.context ().get<size_t> ("comp-number"));
os << "void " << ename (type_) << "::" << endl
<< "sequence_" << n << " (unsigned long& state," << endl
@@ -963,7 +985,7 @@ namespace CXX
<< "switch (state)"
<< "{";
- UnsignedLong state (0);
+ size_t state (0);
for (Compositor::ContainsIterator ci (s.contains_begin ()),
ce (s.contains_end ()); ci != ce;)
@@ -986,7 +1008,7 @@ namespace CXX
ci->particle ().is_a<Compositor> () &&
!ci->particle ().context().count ("comp-number"));
- UnsignedLong next (ci == ce ? 0 : state + 1);
+ size_t next (ci == ce ? 0 : state + 1);
ParticleInSequence t (*this, state++, next, type_);
t.dispatch (p);
@@ -1014,12 +1036,12 @@ namespace CXX
Traversal::Compositor,
Context
{
- CompositorPre (Context& c, SemanticGraph::Complex& type)
- : Context (c), type_ (type)
+ CompositorPre (Context& c)
+ : Context (c)
{
}
- virtual Void
+ virtual void
traverse (SemanticGraph::All& a)
{
// Clear the counts and push the initial state.
@@ -1031,7 +1053,7 @@ namespace CXX
traverse (c);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Compositor&) // Choice and sequence.
{
os << "v_state_& vs = *static_cast< v_state_* > (" <<
@@ -1042,9 +1064,6 @@ namespace CXX
<< "vd.state = 0;"
<< "vd.count = 0;";
}
-
- private:
- SemanticGraph::Complex& type_;
};
@@ -1060,7 +1079,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (SemanticGraph::All&)
{
// The 'all' state machine reaches the final state only
@@ -1078,14 +1097,14 @@ namespace CXX
<< endl;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Compositor& c) // Choice and sequence.
{
using SemanticGraph::Compositor;
- UnsignedLong max (c.max ());
- UnsignedLong min (c.context ().get<UnsignedLong> ("effective-min"));
- UnsignedLong n (c.context ().get<UnsignedLong> ("comp-number"));
+ size_t max (c.max ());
+ size_t min (c.context ().get<size_t> ("effective-min"));
+ size_t n (c.context ().get<size_t> ("comp-number"));
String func (c.is_a<SemanticGraph::Choice> () ?
"choice_" : "sequence_");
@@ -1117,7 +1136,7 @@ namespace CXX
<< "unsigned long s = ~0UL;"
<< endl;
- Boolean first (true);
+ bool first (true);
// Note that we don't need to worry about the compositor
// being empty - this case is handled by our caller.
@@ -1133,7 +1152,7 @@ namespace CXX
if (!p.context ().count ("prefix"))
break;
- UnsignedLong state (p.context ().get<UnsignedLong> ("state"));
+ size_t state (p.context ().get<size_t> ("state"));
if (first)
first = false;
@@ -1230,12 +1249,12 @@ namespace CXX
Traversal::Compositor,
Context
{
- CompositorEndElement (Context& c, SemanticGraph::Complex& type)
- : Context (c), type_ (type)
+ CompositorEndElement (Context& c)
+ : Context (c)
{
}
- virtual Void
+ virtual void
traverse (SemanticGraph::All&)
{
os << "all_0 (vd.state, v_all_count_.top (), " <<
@@ -1243,7 +1262,7 @@ namespace CXX
<< endl;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Compositor&) // Choice and sequence.
{
os << "assert (vd.func != 0);"
@@ -1253,9 +1272,6 @@ namespace CXX
<< "vs.size--;" // pop
<< endl;
}
-
- private:
- SemanticGraph::Complex& type_;
};
@@ -1265,12 +1281,12 @@ namespace CXX
Traversal::Compositor,
Context
{
- CompositorPost (Context& c, SemanticGraph::Complex& type)
- : Context (c), type_ (type), particle_name_ (c)
+ CompositorPost (Context& c)
+ : Context (c), particle_name_ (c)
{
}
- virtual Void
+ virtual void
traverse (SemanticGraph::All& a)
{
using SemanticGraph::Element;
@@ -1289,7 +1305,7 @@ namespace CXX
<< "all_0 (vd.state, v_all_count_.top (), empty, empty, 0, true);"
<< "}";
- if (a.context ().get<UnsignedLong> ("effective-min") != 0)
+ if (a.context ().get<size_t> ("effective-min") != 0)
{
os << "else" << endl
<< "this->_expected_element (" << endl;
@@ -1304,10 +1320,10 @@ namespace CXX
<< "v_all_count_.pop ();";
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Compositor& c) // Choice and sequence.
{
- UnsignedLong min (c.context ().get<UnsignedLong> ("effective-min"));
+ size_t min (c.context ().get<size_t> ("effective-min"));
os << "v_state_& vs = *static_cast< v_state_* > (" <<
"this->v_state_stack_.top ());"
@@ -1343,7 +1359,6 @@ namespace CXX
}
private:
- SemanticGraph::Complex& type_;
ParticleName particle_name_;
};
@@ -1357,7 +1372,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& c)
{
// Nothing to generate if we don't have any elements and wildcards.
@@ -1374,7 +1389,7 @@ namespace CXX
// Don't use restriction_p here since we don't want special
// treatment of anyType.
//
- Boolean restriction (
+ bool restriction (
c.inherits_p () &&
c.inherits ().is_a<SemanticGraph::Restricts> ());
@@ -1476,7 +1491,7 @@ namespace CXX
}
{
- CompositorEndElement t (*this, c);
+ CompositorEndElement t (*this);
t.dispatch (comp);
}
@@ -1495,7 +1510,7 @@ namespace CXX
<< endl;
{
- CompositorPre t (*this, c);
+ CompositorPre t (*this);
t.dispatch (comp);
}
@@ -1543,7 +1558,7 @@ namespace CXX
}
{
- CompositorPost t (*this, c);
+ CompositorPost t (*this);
t.dispatch (c.contains_compositor ().compositor ());
}
@@ -1559,7 +1574,7 @@ namespace CXX
};
}
- Void
+ void
generate_element_validation_source (Context& ctx)
{
ctx.os << "#include <cassert>" << endl
@@ -1567,7 +1582,7 @@ namespace CXX
Traversal::Schema schema;
- Traversal::Sources sources;
+ Sources sources;
Traversal::Names schema_names;
Namespace ns (ctx);
diff --git a/xsd/xsd/cxx/parser/element-validation-source.hxx b/xsd/xsd/cxx/parser/element-validation-source.hxx
index 544b8f1..b9bd70b 100644
--- a/xsd/xsd/cxx/parser/element-validation-source.hxx
+++ b/xsd/xsd/cxx/parser/element-validation-source.hxx
@@ -1,6 +1,5 @@
// file : xsd/cxx/parser/element-validation-source.hxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#ifndef CXX_PARSER_ELEMENT_VALIDATION_SOURCE_HXX
@@ -12,7 +11,7 @@ namespace CXX
{
namespace Parser
{
- Void
+ void
generate_element_validation_source (Context&);
}
}
diff --git a/xsd/xsd/cxx/parser/elements.cxx b/xsd/xsd/cxx/parser/elements.cxx
index b3458c7..889eea4 100644
--- a/xsd/xsd/cxx/parser/elements.cxx
+++ b/xsd/xsd/cxx/parser/elements.cxx
@@ -1,6 +1,5 @@
// file : xsd/cxx/parser/elements.cxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#include <cxx/parser/elements.hxx>
@@ -9,60 +8,16 @@ namespace CXX
{
namespace Parser
{
- // Keep this symbol first to help HP-UX linker (long symbols?).
- //
- Content::Value Context::
- content (SemanticGraph::Complex& c)
- {
- using namespace SemanticGraph;
-
- if (c.mixed_p ())
- return Content::mixed;
-
- if (c.inherits_p ())
- {
- Type& base (c.inherits ().base ());
-
- if (Complex* cb = dynamic_cast<Complex*> (&base))
- return content (*cb);
-
- if (base.is_a<AnyType> ())
- return Content::complex;
-
- // Everyhting else (built-in type and AnySimpleType) is simple
- // content.
- //
- return Content::simple;
- }
- else
- return Content::complex;
- }
-
Context::
Context (std::wostream& o,
SemanticGraph::Schema& root,
SemanticGraph::Path const& path,
- CLI::Options const& ops,
+ options_type const& ops,
StringLiteralMap const* map,
Regex const* he,
Regex const* ie,
Regex const* hie)
- : CXX::Context (o,
- root,
- path,
- map,
- ops.value<CLI::char_type> (),
- ops.value<CLI::char_encoding> (),
- ops.value<CLI::include_with_brackets> (),
- ops.value<CLI::include_prefix> (),
- ops.value<CLI::export_symbol> (),
- ops.value<CLI::namespace_map> (),
- ops.value<CLI::namespace_regex> (),
- ops.value<CLI::namespace_regex_trace> (),
- ops.value<CLI::include_regex> (),
- ops.value<CLI::include_regex_trace> (),
- ops.value<CLI::generate_inline> (),
- ops.value<CLI::reserved_name> ()),
+ : CXX::Context (o, root, path, ops, map),
options (ops),
xml_parser (xml_parser_),
simple_base (simple_base_),
@@ -77,11 +32,11 @@ namespace CXX
hxx_expr (he),
ixx_expr (ie),
hxx_impl_expr (hie),
- xml_parser_ (ops.value<CLI::xml_parser> ()),
- validation_ ((ops.value<CLI::xml_parser> () == "expat" ||
- ops.value<CLI::generate_validation> ()) &&
- !ops.value<CLI::suppress_validation> ()),
- polymorphic_ (ops.value<CLI::generate_polymorphic> ())
+ xml_parser_ (ops.xml_parser ()),
+ validation_ ((ops.xml_parser () == "expat" ||
+ ops.generate_validation ()) &&
+ !ops.suppress_validation ()),
+ polymorphic_ (ops.generate_polymorphic ())
{
if (char_type == L"char")
std_string_type = L"::std::string";
@@ -144,7 +99,34 @@ namespace CXX
{
}
- Boolean Context::
+ Content::Value Context::
+ content (SemanticGraph::Complex& c)
+ {
+ using namespace SemanticGraph;
+
+ if (c.mixed_p ())
+ return Content::mixed;
+
+ if (c.inherits_p ())
+ {
+ Type& base (c.inherits ().base ());
+
+ if (Complex* cb = dynamic_cast<Complex*> (&base))
+ return content (*cb);
+
+ if (base.is_a<AnyType> ())
+ return Content::complex;
+
+ // Everyhting else (built-in type and AnySimpleType) is simple
+ // content.
+ //
+ return Content::simple;
+ }
+ else
+ return Content::complex;
+ }
+
+ bool Context::
anonymous (SemanticGraph::Type& t)
{
return t.context ().count ("anonymous");
@@ -181,12 +163,6 @@ namespace CXX
}
String const& Context::
- emember_cache (SemanticGraph::Member& m)
- {
- return m.context ().get<String> ("member-cache");
- }
-
- String const& Context::
emember_map (SemanticGraph::Member& m)
{
return m.context ().get<String> ("member-map");
@@ -200,20 +176,20 @@ namespace CXX
// Includes
//
- Void TypeForward::
+ void TypeForward::
traverse (SemanticGraph::Type& t)
{
os << "class " << t.context ().get<String> (name_key_) << ";";
}
- Void Includes::
+ void Includes::
traverse_ (SemanticGraph::Uses& u)
{
// Support for weak (forward) inclusion used in the file-per-type
// compilation model.
//
SemanticGraph::Schema& s (u.schema ());
- Boolean weak (u.context ().count ("weak"));
+ bool weak (u.context ().count ("weak"));
if (weak && (type_ == header || type_ == impl_header))
{
@@ -233,6 +209,7 @@ namespace CXX
s.context ().count ("renamed")
? s.context ().get<SemanticGraph::Path> ("renamed")
: u.path ());
+ path.normalize ();
// Try to use the portable representation of the path. If that
// fails, fall back to the native representation.
@@ -240,15 +217,11 @@ namespace CXX
NarrowString path_str;
try
{
- path_str = path.string ();
+ path_str = path.posix_string ();
}
catch (SemanticGraph::InvalidPath const&)
{
-#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2
- path_str = path.native_file_string ();
-#else
path_str = path.string ();
-#endif
}
String inc_path;
@@ -258,12 +231,12 @@ namespace CXX
case header:
case source:
{
- inc_path = ctx_.hxx_expr->merge (path_str);
+ inc_path = ctx_.hxx_expr->replace (path_str);
break;
}
case impl_header:
{
- inc_path = ctx_.hxx_impl_expr->merge (path_str);
+ inc_path = ctx_.hxx_impl_expr->replace (path_str);
break;
}
}
diff --git a/xsd/xsd/cxx/parser/elements.hxx b/xsd/xsd/cxx/parser/elements.hxx
index ee5ca86..31f5d87 100644
--- a/xsd/xsd/cxx/parser/elements.hxx
+++ b/xsd/xsd/cxx/parser/elements.hxx
@@ -1,6 +1,5 @@
// file : xsd/cxx/parser/elements.hxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#ifndef CXX_PARSER_ELEMENTS_HXX
@@ -8,11 +7,13 @@
#include <sstream>
-#include <backend-elements/regex.hxx>
+#include <cutl/re.hxx>
+
+#include <types.hxx>
#include <cxx/elements.hxx>
-#include <cxx/parser/cli.hxx>
+#include <cxx/parser/options.hxx>
namespace CXX
{
@@ -33,13 +34,15 @@ namespace CXX
class Context: public CXX::Context
{
public:
- typedef BackendElements::Regex::Expression<Char> Regex;
+ typedef cutl::re::regexsub Regex;
+
+ typedef Parser::options options_type;
public:
Context (std::wostream&,
SemanticGraph::Schema&,
SemanticGraph::Path const& path,
- CLI::Options const&,
+ options_type const&,
StringLiteralMap const*,
Regex const* hxx_expr,
Regex const* ixx_expr,
@@ -50,7 +53,7 @@ namespace CXX
Context (Context& c, std::wostream& o);
public:
- Boolean
+ bool
restriction_p (SemanticGraph::Complex& c) const
{
if (c.inherits_p () &&
@@ -69,7 +72,7 @@ namespace CXX
content (SemanticGraph::Complex&);
public:
- static Boolean
+ static bool
anonymous (SemanticGraph::Type&);
public:
@@ -90,9 +93,6 @@ namespace CXX
emember (SemanticGraph::Member&);
static String const&
- emember_cache (SemanticGraph::Member&);
-
- static String const&
emember_map (SemanticGraph::Member&);
public:
@@ -100,7 +100,7 @@ namespace CXX
eimpl (SemanticGraph::Type&);
public:
- CLI::Options const& options;
+ options_type const& options;
String& xml_parser;
String& simple_base;
String& complex_base;
@@ -109,8 +109,8 @@ namespace CXX
String& cerr_inst;
String& parser_map;
String& std_string_type;
- Boolean& validation;
- Boolean& polymorphic;
+ bool& validation;
+ bool& polymorphic;
Regex const* hxx_expr;
Regex const* ixx_expr;
@@ -125,20 +125,20 @@ namespace CXX
String cerr_inst_;
String parser_map_;
String std_string_type_;
- Boolean validation_;
- Boolean polymorphic_;
+ bool validation_;
+ bool polymorphic_;
};
//
//
struct RequiredAttributeTest: Traversal::Attribute
{
- RequiredAttributeTest (Boolean& result)
+ RequiredAttributeTest (bool& result)
: result_ (result)
{
}
- virtual Void
+ virtual void
traverse (Type& a)
{
if (!result_ && !a.optional_p ())
@@ -146,7 +146,7 @@ namespace CXX
}
private:
- Boolean& result_;
+ bool& result_;
};
//
@@ -156,14 +156,14 @@ namespace CXX
Traversal::Member,
Context
{
- ParserParamDecl (Context& c, Boolean name_arg)
+ ParserParamDecl (Context& c, bool name_arg)
: Context (c), first_ (true), name_arg_ (name_arg)
{
inherits_ >> *this;
names_ >> *this;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Complex& c)
{
inherits (c, inherits_);
@@ -172,7 +172,7 @@ namespace CXX
names (c, names_);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::List& l)
{
if (!first_)
@@ -188,7 +188,7 @@ namespace CXX
os << " /* " << comment (l.name ()) << " item */";
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Member& m)
{
if (skip (m)) return;
@@ -210,8 +210,8 @@ namespace CXX
Traversal::Inherits inherits_;
Traversal::Names names_;
- Boolean first_;
- Boolean name_arg_;
+ bool first_;
+ bool name_arg_;
};
@@ -219,16 +219,16 @@ namespace CXX
//
struct TypeForward: Traversal::Type, Context
{
- TypeForward (Context& c, Char const* name_key)
+ TypeForward (Context& c, char const* name_key)
: Context (c), name_key_ (name_key)
{
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Type& t);
private:
- Char const* name_key_;
+ char const* name_key_;
};
struct Includes: Traversal::Imports,
@@ -250,20 +250,20 @@ namespace CXX
schema_ >> schema_names_ >> namespace_ >> names_ >> type_forward_;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Imports& i)
{
traverse_ (i);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Includes& i)
{
traverse_ (i);
}
private:
- Void
+ void
traverse_ (SemanticGraph::Uses&);
private:
@@ -281,21 +281,23 @@ namespace CXX
//
struct RootElement: Traversal::Element
{
- RootElement (CLI::Options const& options,
+ typedef Parser::options options_type;
+
+ RootElement (options_type const& options,
SemanticGraph::Element*& element)
: options_ (options), element_ (element)
{
}
- virtual Void
+ virtual void
traverse (Type& e)
{
- if (options_.value<CLI::root_element_first> ())
+ if (options_.root_element_first ())
{
if (element_ == 0)
element_ = &e;
}
- else if (String name = options_.value<CLI::root_element> ())
+ else if (String name = options_.root_element ())
{
if (e.name () == name)
element_ = &e;
@@ -305,7 +307,7 @@ namespace CXX
}
private:
- CLI::Options const& options_;
+ options_type const& options_;
SemanticGraph::Element*& element_;
};
}
diff --git a/xsd/xsd/cxx/parser/generator.cxx b/xsd/xsd/cxx/parser/generator.cxx
index b3aee76..e17986b 100644
--- a/xsd/xsd/cxx/parser/generator.cxx
+++ b/xsd/xsd/cxx/parser/generator.cxx
@@ -1,8 +1,19 @@
// file : xsd/cxx/parser/generator.cxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+#include <algorithm>
+#include <iostream>
+#include <fstream>
+
+#include <cutl/re.hxx>
+
+#include <cutl/compiler/code-stream.hxx>
+#include <cutl/compiler/cxx-indenter.hxx>
+#include <cutl/compiler/sloc-counter.hxx>
+
+#include <xsd-frontend/semantic-graph.hxx>
+
#include <type-map/lexer.hxx>
#include <type-map/parser.hxx>
#include <type-map/type-map.hxx>
@@ -28,49 +39,28 @@
#include <cxx/parser/attribute-validation-source.hxx>
#include <cxx/parser/characters-validation-source.hxx>
-#include <xsd-frontend/semantic-graph.hxx>
-
-#include <backend-elements/regex.hxx>
-#include <backend-elements/indentation/cxx.hxx>
-#include <backend-elements/indentation/sloc.hxx>
-#include <backend-elements/indentation/clip.hxx>
-
-#include <cult/containers/set.hxx>
-#include <cult/containers/vector.hxx>
-
-#include <boost/filesystem/fstream.hpp>
-
-#include <iostream>
-
-#include <usage.hxx>
+#include <cxx/parser/options.hxx>
#include "../../../libxsd/xsd/cxx/version.hxx"
using std::endl;
using std::wcerr;
+using std::wcout;
using namespace XSDFrontend::SemanticGraph;
//
//
-typedef
-boost::filesystem::wifstream
-WideInputFileStream;
-
-typedef
-boost::filesystem::wofstream
-WideOutputFileStream;
-
-typedef
-boost::filesystem::ifstream
-NarrowInputFileStream;
+typedef std::wifstream WideInputFileStream;
+typedef std::wofstream WideOutputFileStream;
+typedef std::ifstream NarrowInputFileStream;
namespace CXX
{
namespace
{
- Char const copyright_gpl[] =
- "// Copyright (C) 2005-2010 Code Synthesis Tools CC\n"
+ char const copyright_gpl[] =
+ "// Copyright (c) 2005-2014 Code Synthesis Tools CC\n"
"//\n"
"// This program was generated by CodeSynthesis XSD, an XML Schema to\n"
"// C++ data binding compiler.\n"
@@ -103,8 +93,8 @@ namespace CXX
"// in the accompanying FLOSSE file.\n"
"//\n\n";
- Char const copyright_proprietary[] =
- "// Copyright (C) 2005-2010 Code Synthesis Tools CC\n"
+ char const copyright_proprietary[] =
+ "// Copyright (c) 2005-2014 Code Synthesis Tools CC\n"
"//\n"
"// This program was generated by CodeSynthesis XSD, an XML Schema\n"
"// to C++ data binding compiler, in the Proprietary License mode.\n"
@@ -113,7 +103,7 @@ namespace CXX
"// conditions.\n"
"//\n\n";
- Char const copyright_impl[] =
+ char const copyright_impl[] =
"// Not copyrighted - public domain.\n"
"//\n"
"// This sample parser implementation was generated by CodeSynthesis XSD,\n"
@@ -122,442 +112,24 @@ namespace CXX
"//\n\n";
}
- namespace Parser
- {
- namespace CLI
- {
- extern Key type_map = "type-map";
- extern Key char_type = "char-type";
- extern Key char_encoding = "char-encoding";
- extern Key output_dir = "output-dir";
- extern Key xml_parser = "xml-parser";
- extern Key generate_inline = "generate-inline";
- extern Key generate_validation = "generate-validation";
- extern Key suppress_validation = "suppress-validation";
- extern Key generate_polymorphic = "generate-polymorphic";
- extern Key generate_noop_impl = "generate-noop-impl";
- extern Key generate_print_impl = "generate-print-impl";
- extern Key generate_test_driver = "generate-test-driver";
- extern Key force_overwrite = "force-overwrite";
- extern Key root_element_first = "root-element-first";
- extern Key root_element_last = "root-element-last";
- extern Key root_element = "root-element";
- extern Key generate_xml_schema = "generate-xml-schema";
- extern Key extern_xml_schema = "extern-xml-schema";
- extern Key skel_type_suffix = "skel-type-suffix";
- extern Key skel_file_suffix = "skel-file-suffix";
- extern Key impl_type_suffix = "impl-type-suffix";
- extern Key impl_file_suffix = "impl-file-suffix";
- extern Key namespace_map = "namespace-map";
- extern Key namespace_regex = "namespace-regex";
- extern Key namespace_regex_trace = "namespace-regex-trace";
- extern Key reserved_name = "reserved-name";
- extern Key include_with_brackets = "include-with-brackets";
- extern Key include_prefix = "include-prefix";
- extern Key include_regex = "include-regex";
- extern Key include_regex_trace = "include-regex-trace";
- extern Key guard_prefix = "guard-prefix";
- extern Key hxx_suffix = "hxx-suffix";
- extern Key ixx_suffix = "ixx-suffix";
- extern Key cxx_suffix = "cxx-suffix";
- extern Key hxx_regex = "hxx-regex";
- extern Key ixx_regex = "ixx-regex";
- extern Key cxx_regex = "cxx-regex";
- extern Key hxx_prologue = "hxx-prologue";
- extern Key ixx_prologue = "ixx-prologue";
- extern Key cxx_prologue = "cxx-prologue";
- extern Key prologue = "prologue";
- extern Key hxx_epilogue = "hxx-epilogue";
- extern Key ixx_epilogue = "ixx-epilogue";
- extern Key cxx_epilogue = "cxx-epilogue";
- extern Key epilogue = "epilogue";
- extern Key hxx_prologue_file = "hxx-prologue-file";
- extern Key ixx_prologue_file = "ixx-prologue-file";
- extern Key cxx_prologue_file = "cxx-prologue-file";
- extern Key prologue_file = "prologue-file";
- extern Key hxx_epilogue_file = "hxx-epilogue-file";
- extern Key ixx_epilogue_file = "ixx-epilogue-file";
- extern Key cxx_epilogue_file = "cxx-epilogue-file";
- extern Key epilogue_file = "epilogue-file";
- extern Key export_symbol = "export-symbol";
- extern Key export_maps = "export-maps";
- extern Key import_maps = "import-maps";
- extern Key show_anonymous = "show-anonymous";
- extern Key show_sloc = "show-sloc";
- extern Key proprietary_license = "proprietary-license";
- }
- }
-
- Void Parser::Generator::
+ void Parser::Generator::
usage ()
{
- std::wostream& e (wcerr);
- ::CLI::Indent::Clip< ::CLI::OptionsUsage, WideChar> clip (e);
-
- e << "--type-map <mapfile>" << endl
- << " Read XML Schema to C++ type mapping information\n"
- << " from <mapfile>. Repeat this option to specify\n"
- << " several type maps. Type maps are considered in\n"
- << " order of appearance and the first match is used."
- << endl;
-
- e << "--char-type <type>" << endl
- << " Use <type> as the base character type. Valid\n"
- << " values are 'char' (default) and 'wchar_t'."
- << endl;
-
- e << "--char-encoding <enc>" << endl
- << " Specify the character encoding that should be used\n"
- << " in the object model. Valid values for the 'char'\n"
- << " character type are 'utf8' (default), 'iso8859-1',\n"
- << " 'lcp', and 'custom'. For the 'wchar_t' character\n"
- << " type the only valid value is 'auto'."
- << endl;
-
- e << "--output-dir <dir>" << endl
- << " Write generated files to <dir> instead of current\n"
- << " directory."
- << endl;
-
- e << "--xml-parser <parser>" << endl
- << " Use <parser> as the underlying XML parser. Valid\n"
- << " values are 'xerces' (default) and 'expat'."
- << endl;
-
- e << "--generate-inline" << endl
- << " Generate certain functions inline."
- << endl;
-
- e << "--generate-validation" << endl
- << " Generate validation code."
- << endl;
-
- e << "--suppress-validation" << endl
- << " Suppress the generation of validation code."
- << endl;
-
- e << "--generate-polymorphic" << endl
- << " Generate polymorphism-aware code. Specify this\n"
- << " option if you use substitution groups or xsi:type."
- << endl;
-
- e << "--generate-noop-impl" << endl
- << " Generate a sample parser implementation that\n"
- << " does nothing (no operation)."
- << endl;
-
- e << "--generate-print-impl" << endl
- << " Generate a sample parser implementation that\n"
- << " prints the XML data to STDOUT."
- << endl;
-
- e << "--generate-test-driver" << endl
- << " Generate a test driver for the sample parser\n"
- << " implementation."
- << endl;
-
- e << "--force-overwrite" << endl
- << " Force overwriting of the existing implementation\n"
- << " and test driver files."
- << endl;
-
- e << "--root-element-first" << endl
- << " Indicate that the first global element is the\n"
- << " document root."
- << endl;
-
- e << "--root-element-last" << endl
- << " Indicate that the last global element is the\n"
- << " document root."
- << endl;
-
- e << "--root-element <element>" << endl
- << " Indicate that <element> is the document root."
- << endl;
-
- e << "--generate-xml-schema" << endl
- << " Generate a C++ header file as if the schema being\n"
- << " compiled defines the XML Schema namespace."
- << endl;
-
- e << "--extern-xml-schema <file>" << endl
- << " Generate code as if the XML Schema namespace was\n"
- << " defined in <file> and xsd:included in the schema\n"
- << " being compiled."
- << endl;
-
- e << "--skel-type-suffix <suffix>" << endl
- << " Use <suffix> instead of the default '_pskel' to\n"
- << " construct the names of generated parser skeletons."
- << endl;
-
- e << "--skel-file-suffix <suffix>" << endl
- << " Use <suffix> instead of the default '-pskel' to\n"
- << " construct the names of generated parser skeleton\n"
- << " files."
- << endl;
-
- e << "--impl-type-suffix <suffix>" << endl
- << " Use <suffix> instead of the default '_pimpl' to\n"
- << " construct the names of parser implementations for\n"
- << " the built-in XML Schema types and sample parser\n"
- << " implementations."
- << endl;
-
- e << "--impl-file-suffix <suffix>" << endl
- << " Use <suffix> instead of the default '-pimpl' to\n"
- << " construct the names of generated sample parser\n"
- << " implementation files."
- << endl;
-
- e << "--namespace-map <xns>=<cns>" << endl
- << " Map XML Schema namespace <xns> to C++ namespace\n"
- << " <cns>. Repeat this option to specify mapping for\n"
- << " more than one XML Schema namespace."
- << endl;
-
- e << "--namespace-regex <regex>" << endl
- << " Add <regex> to the list of regular expressions\n"
- << " used to translate XML Schema namespace names to\n"
- << " C++ namespace names."
- << endl;
-
- e << "--namespace-regex-trace" << endl
- << " Trace the process of applying regular expressions\n"
- << " specified with the --namespace-regex option."
- << endl;
-
- e << "--reserved-name <name>" << endl
- << " Add <name> to the list of names that should not\n"
- << " be used as identifiers. The name can optionally\n"
- << " be followed by '=' and the replacement name that\n"
- << " should be used instead."
- << endl;
-
- e << "--include-with-brackets" << endl
- << " Use angle brackets (<>) instead of quotes (\"\") in\n"
- << " generated #include directives."
- << endl;
-
- e << "--include-prefix <prefix>" << endl
- << " Add <prefix> to generated #include directive\n"
- << " paths."
- << endl;
-
- e << "--include-regex <regex>" << endl
- << " Add <regex> to the list of regular expressions\n"
- << " used to transform #include directive paths."
- << endl;
-
- e << "--include-regex-trace" << endl
- << " Trace the process of applying regular expressions\n"
- << " specified with the --include-regex option."
- << endl;
-
- e << "--guard-prefix <prefix>" << endl
- << " Add <prefix> to generated header inclusion guards."
- << endl;
-
- e << "--hxx-suffix <suffix>" << endl
- << " Use <suffix> instead of the default '.hxx' to\n"
- << " construct the name of the header file."
- << endl;
-
- e << "--ixx-suffix <suffix>" << endl
- << " Use <suffix> instead of the default '.ixx' to\n"
- << " construct the name of the inline file."
- << endl;
-
- e << "--cxx-suffix <suffix>" << endl
- << " Use <suffix> instead of the default '.cxx' to\n"
- << " construct the name of the source file."
- << endl;
-
- e << "--hxx-regex <regex>" << endl
- << " Use <regex> to construct the name of the header\n"
- << " file."
- << endl;
-
- e << "--ixx-regex <regex>" << endl
- << " Use <regex> to construct the name of the inline\n"
- << " file."
- << endl;
-
- e << "--cxx-regex <regex>" << endl
- << " Use <regex> to construct the name of the source\n"
- << " file."
- << endl;
-
-
- // Prologues.
- //
- e << "--hxx-prologue <text>" << endl
- << " Insert <text> at the beginning of the header file."
- << endl;
-
- e << "--ixx-prologue <text>" << endl
- << " Insert <text> at the beginning of the inline file."
- << endl;
-
- e << "--cxx-prologue <text>" << endl
- << " Insert <text> at the beginning of the source file."
- << endl;
-
- e << "--prologue <text>" << endl
- << " Insert <text> at the beginning of each generated\n"
- << " file for which there is no file-specific prologue."
- << endl;
-
-
- // Epilogues.
- //
- e << "--hxx-epilogue <text>" << endl
- << " Insert <text> at the end of the header file."
- << endl;
-
- e << "--ixx-epilogue <text>" << endl
- << " Insert <text> at the end of the inline file."
- << endl;
-
- e << "--cxx-epilogue <text>" << endl
- << " Insert <text> at the end of the source file."
- << endl;
-
- e << "--epilogue <text>" << endl
- << " Insert <text> at the end of each generated file\n"
- << " for which there is no file-specific epilogue."
- << endl;
-
-
- // Prologue files.
- //
- e << "--hxx-prologue-file <file>" << endl
- << " Insert the content of the <file> at the beginning\n"
- << " of the header file."
- << endl;
-
- e << "--ixx-prologue-file <file>" << endl
- << " Insert the content of the <file> at the beginning\n"
- << " of the inline file."
- << endl;
-
- e << "--cxx-prologue-file <file>" << endl
- << " Insert the content of the <file> at the beginning\n"
- << " of the source file."
- << endl;
-
- e << "--prologue-file <file>" << endl
- << " Insert the content of the <file> at the beginning\n"
- << " of each generated file for which there is no file-\n"
- << " specific prologue file."
- << endl;
-
-
- // Epilogue files.
- //
- e << "--hxx-epilogue-file <file>" << endl
- << " Insert the content of the <file> at the end of\n"
- << " the header file."
- << endl;
-
- e << "--ixx-epilogue-file <file>" << endl
- << " Insert the content of the <file> at the end of\n"
- << " the inline file."
- << endl;
-
- e << "--cxx-epilogue-file <file>" << endl
- << " Insert the content of the <file> at the end of\n"
- << " the source file."
- << endl;
-
- e << "--epilogue-file <file>" << endl
- << " Insert the content of the <file> at the end of\n"
- << " each generated file for which there is no file-\n"
- << " specific epilogue file."
- << endl;
-
-
- // Misc.
- //
- e << "--custom-literals <file>" << endl
- << " Load custom XML string to C++ literal mappings\n"
- << " from <file>."
- << endl;
-
- e << "--export-symbol <symbol>" << endl
- << " Export symbol for Win32 DLL export/import control."
- << endl;
-
- e << "--export-maps" << endl
- << " Export polymorphism support maps from Win32 DLL."
- << endl;
-
- e << "--import-maps" << endl
- << " Import polymorphism support maps from Win32 DLL."
- << endl;
-
- e << "--show-anonymous" << endl
- << " Show elements and attributes that are of anonymous\n"
- << " types."
- << endl;
-
- e << "--show-sloc" << endl
- << " Show the number of generated physical source lines\n"
- << " of code (SLOC)."
- << endl;
-
- e << "--sloc-limit <num>" << endl
- << " Check that the number of generated physical source\n"
- << " lines of code (SLOC) does not exceed <num>."
- << endl;
-
- e << "--options-file <file>" << endl
- << " Read additional options from <file>. Each option\n"
- << " should appear on a separate line optionally\n"
- << " followed by space and an argument."
- << endl;
-
- e << "--proprietary-license" << endl
- << " Indicate that the generated code is licensed under\n"
- << " a proprietary license instead of the GPL."
- << endl;
+ CXX::Parser::options::print_usage (wcout);
+ CXX::options::print_usage (wcout);
}
- Parser::CLI::OptionsSpec Parser::Generator::
- options_spec ()
- {
- CLI::OptionsSpec spec;
-
- spec.option<CLI::char_type> ().default_value ("char");
- spec.option<CLI::xml_parser> ().default_value ("xerces");
-
- spec.option<CLI::skel_file_suffix> ().default_value ("-pskel");
- spec.option<CLI::skel_type_suffix> ().default_value ("_pskel");
- spec.option<CLI::impl_file_suffix> ().default_value ("-pimpl");
- spec.option<CLI::impl_type_suffix> ().default_value ("_pimpl");
-
- spec.option<CLI::hxx_suffix> ().default_value (".hxx");
- spec.option<CLI::ixx_suffix> ().default_value (".ixx");
- spec.option<CLI::cxx_suffix> ().default_value (".cxx");
-
- return spec;
- }
-
-
namespace
{
template <typename S>
- Void
+ void
open (S& ifs, NarrowString const& path)
{
try
{
-#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2
- Path fs_path (path, boost::filesystem::native);
-#else
- Path fs_path (path.c_str());
-#endif
- ifs.open (fs_path, std::ios_base::in | std::ios_base::binary);
+ Path fs_path (path);
+ ifs.open (fs_path.string ().c_str (),
+ std::ios_base::in | std::ios_base::binary);
if (!ifs.is_open ())
{
@@ -576,7 +148,7 @@ namespace CXX
}
}
- Void
+ void
append (WideOutputFileStream& os,
NarrowString const& path,
WideInputFileStream& default_is)
@@ -596,16 +168,15 @@ namespace CXX
}
}
- Void
+ void
append (WideOutputFileStream& os,
- Cult::Containers::Vector<NarrowString> const& primary,
- Cult::Containers::Vector<NarrowString> const& def)
+ NarrowStrings const& primary,
+ NarrowStrings const& def)
{
- Cult::Containers::Vector<NarrowString> const& v (
- primary.empty () ? def : primary);
+ NarrowStrings const& v (primary.empty () ? def : primary);
- for (Containers::Vector<NarrowString>::ConstIterator
- i (v.begin ()), e (v.end ()); i != e; ++i)
+ for (NarrowStrings::const_iterator i (v.begin ()), e (v.end ());
+ i != e; ++i)
{
os << i->c_str () << endl;
}
@@ -613,25 +184,24 @@ namespace CXX
}
- UnsignedLong Parser::Generator::
- generate (Parser::CLI::Options const& ops,
+ size_t Parser::Generator::
+ generate (Parser::options const& ops,
Schema& schema,
Path const& file_path,
- Boolean fpt,
+ bool fpt,
StringLiteralMap const& string_literal_map,
- Boolean gen_driver,
+ bool gen_driver,
const WarningSet& disabled_warnings,
FileList& file_list,
AutoUnlinks& unlinks)
{
using std::ios_base;
- namespace Indentation = BackendElements::Indentation;
- typedef BackendElements::Regex::Expression<Char> Regex;
+ typedef cutl::re::regexsub Regex;
try
{
- Boolean generate_xml_schema (ops.value<CLI::generate_xml_schema> ());
+ bool generate_xml_schema (ops.generate_xml_schema ());
// We could be compiling several schemas at once in which case
// handling of the --generate-xml-schema option gets tricky: we
@@ -640,23 +210,19 @@ namespace CXX
//
if (generate_xml_schema)
{
- if (NarrowString name = ops.value<CLI::extern_xml_schema> ())
+ if (NarrowString name = ops.extern_xml_schema ())
{
-#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2
- if (file_path.native_file_string () != name)
-#else
if (file_path.string () != name)
-#endif
generate_xml_schema = false;
}
}
- Boolean impl (!generate_xml_schema &&
- (ops.value<CLI::generate_noop_impl> () ||
- ops.value<CLI::generate_print_impl> ()));
+ bool impl (!generate_xml_schema &&
+ (ops.generate_noop_impl () ||
+ ops.generate_print_impl ()));
- Boolean driver (gen_driver && !generate_xml_schema &&
- ops.value<CLI::generate_test_driver> ());
+ bool driver (gen_driver && !generate_xml_schema &&
+ ops.generate_test_driver ());
// Evaluate the graph for possibility of generating something useful.
//
@@ -674,9 +240,9 @@ namespace CXX
proc.process (ops, schema, file_path, string_literal_map);
}
- Boolean validation ((ops.value<CLI::xml_parser> () == "expat" ||
- ops.value<CLI::generate_validation> ()) &&
- !ops.value<CLI::suppress_validation> ());
+ bool validation ((ops.xml_parser () == "expat" ||
+ ops.generate_validation ()) &&
+ !ops.suppress_validation ());
// Compute state machine info.
//
@@ -691,11 +257,11 @@ namespace CXX
TypeMap::Namespaces type_map;
{
using namespace TypeMap;
- typedef Containers::Vector<NarrowString> Files;
- Files const& files (ops.value<CLI::type_map> ());
+ NarrowStrings const& files (ops.type_map ());
- for (Files::ConstIterator f (files.begin ()); f != files.end (); ++f )
+ for (NarrowStrings::const_iterator f (files.begin ());
+ f != files.end (); ++f )
{
NarrowInputFileStream ifs;
open (ifs, *f);
@@ -712,7 +278,7 @@ namespace CXX
// String-based types.
//
- String char_type (ops.value<CLI::char_type> ());
+ String char_type (ops.char_type ());
String string_type;
if (char_type == L"char")
@@ -723,12 +289,14 @@ namespace CXX
string_type = L"::std::basic_string< " + char_type + L" >";
String xns;
+ String auto_ptr;
{
Context ctx (std::wcerr, schema, file_path, ops, 0, 0, 0, 0);
xns = ctx.xs_ns_name ();
+ auto_ptr = ctx.auto_ptr;
}
- String buffer (L"::std::auto_ptr< " + xns + L"::buffer >");
+ String buffer (auto_ptr + L"< " + xns + L"::buffer >");
TypeMap::Namespace xsd ("http://www\\.w3\\.org/2001/XMLSchema");
xsd.types_push_back ("string", string_type);
@@ -800,7 +368,7 @@ namespace CXX
type_map.push_back (xsd);
- // Everyhting else maps to void.
+ // Everything else maps to void.
//
TypeMap::Namespace rest (".*");
rest.types_push_back (".*", "void", "void");
@@ -816,39 +384,33 @@ namespace CXX
//
//
- Boolean inline_ (ops.value<CLI::generate_inline> () &&
- !generate_xml_schema);
-
- Boolean source (!generate_xml_schema);
+ bool inline_ (ops.generate_inline () && !generate_xml_schema);
+ bool source (!generate_xml_schema);
// Generate code.
//
-#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2
- NarrowString name (file_path.leaf ());
-#else
- NarrowString name (file_path.filename().string());
-#endif
- NarrowString skel_suffix (ops.value <CLI::skel_file_suffix> ());
- NarrowString impl_suffix (ops.value <CLI::impl_file_suffix> ());
-
- NarrowString hxx_suffix (ops.value <CLI::hxx_suffix> ());
- NarrowString ixx_suffix (ops.value <CLI::ixx_suffix> ());
- NarrowString cxx_suffix (ops.value <CLI::cxx_suffix> ());
+ NarrowString name (file_path.leaf ().string ());
+ NarrowString skel_suffix (ops.skel_file_suffix ());
+ NarrowString impl_suffix (ops.impl_file_suffix ());
+
+ NarrowString hxx_suffix (ops.hxx_suffix ());
+ NarrowString ixx_suffix (ops.ixx_suffix ());
+ NarrowString cxx_suffix (ops.cxx_suffix ());
Regex hxx_expr (
- ops.value <CLI::hxx_regex> ().empty ()
+ ops.hxx_regex ().empty ()
? "#^(.+?)(\\.[^./\\\\]+)?$#$1" + skel_suffix + hxx_suffix + "#"
- : ops.value <CLI::hxx_regex> ());
+ : ops.hxx_regex ());
Regex ixx_expr (
- ops.value <CLI::ixx_regex> ().empty ()
+ ops.ixx_regex ().empty ()
? "#^(.+?)(\\.[^./\\\\]+)?$#$1" + skel_suffix + ixx_suffix + "#"
- : ops.value <CLI::ixx_regex> ());
+ : ops.ixx_regex ());
Regex cxx_expr (
- ops.value <CLI::cxx_regex> ().empty ()
+ ops.cxx_regex ().empty ()
? "#^(.+?)(\\.[^./\\\\]+)?$#$1" + skel_suffix + cxx_suffix + "#"
- : ops.value <CLI::cxx_regex> ());
+ : ops.cxx_regex ());
Regex hxx_impl_expr;
@@ -870,7 +432,7 @@ namespace CXX
if (!hxx_expr.match (name))
{
wcerr << "error: header expression '" <<
- hxx_expr.pattern () << "' does not match '" <<
+ hxx_expr.regex ().str ().c_str () << "' does not match '" <<
name.c_str () << "'" << endl;
throw Failed ();
}
@@ -878,7 +440,7 @@ namespace CXX
if (inline_ && !ixx_expr.match (name))
{
wcerr << "error: inline expression '" <<
- ixx_expr.pattern () << "' does not match '" <<
+ ixx_expr.regex ().str ().c_str () << "' does not match '" <<
name.c_str () << "'" << endl;
throw Failed ();
}
@@ -886,7 +448,7 @@ namespace CXX
if (source && !cxx_expr.match (name))
{
wcerr << "error: source expression '" <<
- cxx_expr.pattern () << "' does not match '" <<
+ cxx_expr.regex ().str ().c_str () << "' does not match '" <<
name.c_str () << "'" << endl;
throw Failed ();
}
@@ -896,7 +458,7 @@ namespace CXX
if (!hxx_impl_expr.match (name))
{
wcerr << "error: implementation header expression '" <<
- hxx_impl_expr.pattern () << "' does not match '" <<
+ hxx_impl_expr.regex ().str ().c_str () << "' does not match '" <<
name.c_str () << "'" << endl;
throw Failed ();
}
@@ -904,7 +466,7 @@ namespace CXX
if (!cxx_impl_expr.match (name))
{
wcerr << "error: implementation source expression '" <<
- cxx_impl_expr.pattern () << "' does not match '" <<
+ cxx_impl_expr.regex ().str ().c_str () << "' does not match '" <<
name.c_str () << "'" << endl;
throw Failed ();
}
@@ -912,15 +474,15 @@ namespace CXX
if (!cxx_driver_expr.match (name))
{
wcerr << "error: driver source expression '" <<
- cxx_driver_expr.pattern () << "' does not match '" <<
+ cxx_driver_expr.regex ().str ().c_str () << "' does not match '" <<
name.c_str () << "'" << endl;
throw Failed ();
}
}
- NarrowString hxx_name (hxx_expr.merge (name));
- NarrowString ixx_name (inline_ ? ixx_expr.merge (name) : NarrowString ());
- NarrowString cxx_name (source ? cxx_expr.merge (name) : NarrowString ());
+ NarrowString hxx_name (hxx_expr.replace (name));
+ NarrowString ixx_name (inline_ ? ixx_expr.replace (name) : NarrowString ());
+ NarrowString cxx_name (source ? cxx_expr.replace (name) : NarrowString ());
NarrowString hxx_impl_name;
NarrowString cxx_impl_name;
@@ -928,20 +490,14 @@ namespace CXX
if (impl || driver)
{
- hxx_impl_name = hxx_impl_expr.merge (name);
- cxx_impl_name = cxx_impl_expr.merge (name);
- cxx_driver_name = cxx_driver_expr.merge (name);
+ hxx_impl_name = hxx_impl_expr.replace (name);
+ cxx_impl_name = cxx_impl_expr.replace (name);
+ cxx_driver_name = cxx_driver_expr.replace (name);
}
-#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2
- Path hxx_path (hxx_name, boost::filesystem::native);
- Path ixx_path (ixx_name, boost::filesystem::native);
- Path cxx_path (cxx_name, boost::filesystem::native);
-#else
- Path hxx_path (hxx_name.c_str());
- Path ixx_path (ixx_name.c_str());
- Path cxx_path (cxx_name.c_str());
-#endif
+ Path hxx_path (hxx_name);
+ Path ixx_path (ixx_name);
+ Path cxx_path (cxx_name);
Path hxx_impl_path;
Path cxx_impl_path;
@@ -949,28 +505,18 @@ namespace CXX
if (impl || driver)
{
-#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2
- hxx_impl_path = Path (hxx_impl_name, boost::filesystem::native);
- cxx_impl_path = Path (cxx_impl_name, boost::filesystem::native);
- cxx_driver_path = Path (cxx_driver_name, boost::filesystem::native);
-#else
- hxx_impl_path = Path (hxx_impl_name.c_str());
- cxx_impl_path = Path (cxx_impl_name.c_str());
- cxx_driver_path = Path (cxx_driver_name.c_str());
-#endif
+ hxx_impl_path = Path (hxx_impl_name);
+ cxx_impl_path = Path (cxx_impl_name);
+ cxx_driver_path = Path (cxx_driver_name);
}
Path out_dir;
- if (NarrowString dir = ops.value<CLI::output_dir> ())
+ if (NarrowString dir = ops.output_dir ())
{
try
{
-#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2
- out_dir = Path (dir, boost::filesystem::native);
-#else
- out_dir = Path (dir.c_str());
-#endif
+ out_dir = Path (dir);
}
catch (InvalidPath const&)
{
@@ -985,7 +531,7 @@ namespace CXX
// unless the user added the directory so that we propagate this
// to the output files.
//
- Path fpt_dir (file_path.branch_path ());
+ Path fpt_dir (file_path.directory ());
if (!fpt_dir.empty ())
out_dir /= fpt_dir;
@@ -1014,9 +560,10 @@ namespace CXX
if (impl)
{
- if (!ops.value<CLI::force_overwrite> ())
+ if (!ops.force_overwrite ())
{
- WideInputFileStream tmp (hxx_impl_path, ios_base::in);
+ WideInputFileStream tmp (
+ hxx_impl_path.string ().c_str (), ios_base::in);
if (tmp.is_open ())
{
@@ -1028,7 +575,7 @@ namespace CXX
tmp.close ();
}
- hxx_impl.open (hxx_impl_path, ios_base::out);
+ hxx_impl.open (hxx_impl_path.string ().c_str (), ios_base::out);
if (!hxx_impl.is_open ())
{
@@ -1038,15 +585,12 @@ namespace CXX
}
unlinks.add (hxx_impl_path);
-#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2
- file_list.push_back (hxx_impl_path.native_file_string ());
-#else
file_list.push_back (hxx_impl_path.string ());
-#endif
- if (!ops.value<CLI::force_overwrite> ())
+ if (!ops.force_overwrite ())
{
- WideInputFileStream tmp (cxx_impl_path, ios_base::in);
+ WideInputFileStream tmp (
+ cxx_impl_path.string ().c_str (), ios_base::in);
if (tmp.is_open ())
{
@@ -1058,7 +602,7 @@ namespace CXX
tmp.close ();
}
- cxx_impl.open (cxx_impl_path, ios_base::out);
+ cxx_impl.open (cxx_impl_path.string ().c_str (), ios_base::out);
if (!cxx_impl.is_open ())
{
@@ -1068,18 +612,15 @@ namespace CXX
}
unlinks.add (cxx_impl_path);
-#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2
- file_list.push_back (cxx_impl_path.native_file_string ());
-#else
file_list.push_back (cxx_impl_path.string ());
-#endif
}
if (driver)
{
- if (!ops.value<CLI::force_overwrite> ())
+ if (!ops.force_overwrite ())
{
- WideInputFileStream tmp (cxx_driver_path, ios_base::in);
+ WideInputFileStream tmp (
+ cxx_driver_path.string ().c_str (), ios_base::in);
if (tmp.is_open ())
{
@@ -1091,7 +632,7 @@ namespace CXX
tmp.close ();
}
- cxx_driver.open (cxx_driver_path, ios_base::out);
+ cxx_driver.open (cxx_driver_path.string ().c_str (), ios_base::out);
if (!cxx_driver.is_open ())
{
@@ -1101,16 +642,12 @@ namespace CXX
}
unlinks.add (cxx_driver_path);
-#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2
- file_list.push_back (cxx_driver_path.native_file_string ());
-#else
file_list.push_back (cxx_driver_path.string ());
-#endif
}
// Open the skel files.
//
- WideOutputFileStream hxx (hxx_path, ios_base::out);
+ WideOutputFileStream hxx (hxx_path.string ().c_str (), ios_base::out);
WideOutputFileStream ixx;
WideOutputFileStream cxx;
@@ -1121,15 +658,11 @@ namespace CXX
}
unlinks.add (hxx_path);
-#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2
- file_list.push_back (hxx_path.native_file_string ());
-#else
file_list.push_back (hxx_path.string ());
-#endif
if (inline_)
{
- ixx.open (ixx_path, ios_base::out);
+ ixx.open (ixx_path.string ().c_str (), ios_base::out);
if (!ixx.is_open ())
{
@@ -1138,17 +671,13 @@ namespace CXX
}
unlinks.add (ixx_path);
-#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2
- file_list.push_back (ixx_path.native_file_string ());
-#else
file_list.push_back (ixx_path.string ());
-#endif
}
if (source)
{
- cxx.open (cxx_path, ios_base::out);
+ cxx.open (cxx_path.string ().c_str (), ios_base::out);
if (!cxx.is_open ())
{
@@ -1157,19 +686,13 @@ namespace CXX
}
unlinks.add (cxx_path);
-#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2
- file_list.push_back (cxx_path.native_file_string ());
-#else
file_list.push_back (cxx_path.string ());
-#endif
}
// Print copyright and license.
//
- Char const* copyright (
- ops.value<CLI::proprietary_license> ()
- ? copyright_proprietary
- : copyright_gpl);
+ char const* copyright (
+ ops.proprietary_license () ? copyright_proprietary : copyright_gpl);
hxx << copyright;
@@ -1192,7 +715,7 @@ namespace CXX
//
WideInputFileStream prologue;
{
- NarrowString name (ops.value<CLI::prologue_file> ());
+ NarrowString name (ops.prologue_file ());
if (name)
open (prologue, name);
@@ -1202,7 +725,7 @@ namespace CXX
//
WideInputFileStream epilogue;
{
- NarrowString name (ops.value<CLI::epilogue_file> ());
+ NarrowString name (ops.epilogue_file ());
if (name)
open (epilogue, name);
@@ -1210,21 +733,25 @@ namespace CXX
// SLOC counter.
//
- UnsignedLong sloc (0);
- Boolean show_sloc (ops.value<CLI::show_sloc> ());
+ size_t sloc_total (0);
+ bool show_sloc (ops.show_sloc ());
+
+ typedef
+ compiler::ostream_filter<compiler::cxx_indenter, wchar_t>
+ ind_filter;
+
+ typedef
+ compiler::ostream_filter<compiler::sloc_counter, wchar_t>
+ sloc_filter;
//
//
Regex guard_expr ("/([a-z])([A-Z])/$1_$2/"); // Split words.
- NarrowString guard_prefix (ops.value<CLI::guard_prefix> ());
+ NarrowString guard_prefix (ops.guard_prefix ());
if (!guard_prefix)
-#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2
- guard_prefix = file_path.branch_path ().native_directory_string ();
-#else
- guard_prefix = file_path.branch_path ().string ();
-#endif
+ guard_prefix = file_path.directory ().string ();
if (guard_prefix)
guard_prefix += '_';
@@ -1241,9 +768,9 @@ namespace CXX
&ixx_expr,
&hxx_impl_expr);
- Indentation::Clip<Indentation::SLOC, WideChar> hxx_sloc (hxx);
+ sloc_filter sloc (hxx);
- String guard (guard_expr.merge (guard_prefix + hxx_name));
+ String guard (guard_expr.replace (guard_prefix + hxx_name));
guard = ctx.escape (guard); // Make it a C++ id.
std::transform (guard.begin (), guard.end(), guard.begin (), upcase);
@@ -1251,14 +778,21 @@ namespace CXX
<< "#define " << guard << endl
<< endl;
+ if (ctx.std >= cxx_version::cxx11)
+ {
+ hxx << "#ifndef XSD_CXX11" << endl
+ << "#define XSD_CXX11" << endl
+ << "#endif" << endl
+ << endl;
+ }
+
// Copy prologue.
//
hxx << "// Begin prologue." << endl
<< "//" << endl;
- append (
- hxx, ops.value<CLI::hxx_prologue> (), ops.value<CLI::prologue> ());
- append (hxx, ops.value<CLI::hxx_prologue_file> (), prologue);
+ append (hxx, ops.hxx_prologue (), ops.prologue ());
+ append (hxx, ops.hxx_prologue_file (), prologue);
hxx << "//" << endl
<< "// End prologue." << endl
@@ -1273,38 +807,33 @@ namespace CXX
<< "#endif" << endl
<< endl;
- {
- hxx << "#include <xsd/cxx/pre.hxx>" << endl
- << endl;
-
- // Set auto-indentation.
- //
- Indentation::Clip<Indentation::CXX, WideChar> hxx_clip (hxx);
+ hxx << "#include <xsd/cxx/pre.hxx>" << endl
+ << endl;
+ // Generate.
+ //
+ {
+ ind_filter ind (hxx); // We don't want to indent prologues/epilogues.
- // Generate.
- //
if (!generate_xml_schema)
generate_parser_forward (ctx);
generate_parser_header (ctx, generate_xml_schema);
+ }
+ if (inline_)
+ hxx << "#include " << ctx.process_include_path (ixx_name) << endl;
- if (inline_)
- hxx << "#include " << ctx.process_include_path (ixx_name) << endl;
-
- hxx << "#include <xsd/cxx/post.hxx>" << endl
- << endl;
- }
+ hxx << "#include <xsd/cxx/post.hxx>" << endl
+ << endl;
// Copy epilogue.
//
hxx << "// Begin epilogue." << endl
<< "//" << endl;
- append (hxx, ops.value<CLI::hxx_epilogue_file> (), epilogue);
- append (
- hxx, ops.value<CLI::hxx_epilogue> (), ops.value<CLI::epilogue> ());
+ append (hxx, ops.hxx_epilogue_file (), epilogue);
+ append (hxx, ops.hxx_epilogue (), ops.epilogue ());
hxx << "//" << endl
<< "// End epilogue." << endl
@@ -1313,12 +842,9 @@ namespace CXX
hxx << "#endif // " << guard << endl;
if (show_sloc)
- {
- wcerr << hxx_path << ": "
- << hxx_sloc.buffer ().count () << endl;
+ wcerr << hxx_path << ": " << sloc.stream ().count () << endl;
- sloc += hxx_sloc.buffer ().count ();
- }
+ sloc_total += sloc.stream ().count ();
}
@@ -1335,30 +861,24 @@ namespace CXX
&ixx_expr,
&hxx_impl_expr);
- Indentation::Clip<Indentation::SLOC, WideChar> ixx_sloc (ixx);
-
+ sloc_filter sloc (ixx);
// Copy prologue.
//
ixx << "// Begin prologue." << endl
<< "//" << endl;
- append (
- ixx, ops.value<CLI::ixx_prologue> (), ops.value<CLI::prologue> ());
- append (ixx, ops.value<CLI::ixx_prologue_file> (), prologue);
+ append (ixx, ops.ixx_prologue (), ops.prologue ());
+ append (ixx, ops.ixx_prologue_file (), prologue);
ixx << "//" << endl
<< "// End prologue." << endl
<< endl;
+ // Generate.
+ //
{
- // Set auto-indentation.
- //
- Indentation::Clip<Indentation::CXX, WideChar> ixx_clip (ixx);
-
-
- // Generate.
- //
+ ind_filter ind (ixx); // We don't want to indent prologues/epilogues.
generate_parser_inline (ctx);
}
@@ -1367,21 +887,17 @@ namespace CXX
ixx << "// Begin epilogue." << endl
<< "//" << endl;
- append (ixx, ops.value<CLI::ixx_epilogue_file> (), epilogue);
- append (
- ixx, ops.value<CLI::ixx_epilogue> (), ops.value<CLI::epilogue> ());
+ append (ixx, ops.ixx_epilogue_file (), epilogue);
+ append (ixx, ops.ixx_epilogue (), ops.epilogue ());
ixx << "//" << endl
<< "// End epilogue." << endl
<< endl;
if (show_sloc)
- {
- wcerr << ixx_path << ": "
- << ixx_sloc.buffer ().count () << endl;
+ wcerr << ixx_path << ": " << sloc.stream ().count () << endl;
- sloc += ixx_sloc.buffer ().count ();
- }
+ sloc_total += sloc.stream ().count ();
}
@@ -1398,28 +914,30 @@ namespace CXX
&ixx_expr,
&hxx_impl_expr);
- Indentation::Clip<Indentation::SLOC, WideChar> cxx_sloc (cxx);
+ sloc_filter sloc (cxx);
// Copy prologue.
//
cxx << "// Begin prologue." << endl
<< "//" << endl;
- append (
- cxx, ops.value<CLI::cxx_prologue> (), ops.value<CLI::prologue> ());
- append (cxx, ops.value<CLI::cxx_prologue_file> (), prologue);
+ append (cxx, ops.cxx_prologue (), ops.prologue ());
+ append (cxx, ops.cxx_prologue_file (), prologue);
cxx << "//" << endl
<< "// End prologue." << endl
<< endl;
- {
- // Set auto-indentation.
- //
- Indentation::Clip<Indentation::CXX, WideChar> cxx_clip (cxx);
+ cxx << "#include <xsd/cxx/pre.hxx>" << endl
+ << endl;
- cxx << "#include " << ctx.process_include_path (hxx_name) << endl
- << endl;
+ cxx << "#include " << ctx.process_include_path (hxx_name) << endl
+ << endl;
+
+ // Generate.
+ //
+ {
+ ind_filter ind (cxx); // We don't want to indent prologues/epilogues.
if (!inline_)
generate_parser_inline (ctx);
@@ -1434,26 +952,25 @@ namespace CXX
}
}
+ cxx << "#include <xsd/cxx/post.hxx>" << endl
+ << endl;
+
// Copy epilogue.
//
cxx << "// Begin epilogue." << endl
<< "//" << endl;
- append (cxx, ops.value<CLI::cxx_epilogue_file> (), epilogue);
- append (
- cxx, ops.value<CLI::cxx_epilogue> (), ops.value<CLI::epilogue> ());
+ append (cxx, ops.cxx_epilogue_file (), epilogue);
+ append (cxx, ops.cxx_epilogue (), ops.epilogue ());
cxx << "//" << endl
<< "// End epilogue." << endl
<< endl;
if (show_sloc)
- {
- wcerr << cxx_path << ": "
- << cxx_sloc.buffer ().count () << endl;
+ wcerr << cxx_path << ": " << sloc.stream ().count () << endl;
- sloc += cxx_sloc.buffer ().count ();
- }
+ sloc_total += sloc.stream ().count ();
}
// HXX impl
@@ -1469,7 +986,7 @@ namespace CXX
&ixx_expr,
&hxx_impl_expr);
- String guard (guard_expr.merge (guard_prefix + hxx_impl_name));
+ String guard (guard_expr.replace (guard_prefix + hxx_impl_name));
guard = ctx.escape (guard); // Make it a C++ id.
std::transform (guard.begin (), guard.end(), guard.begin (), upcase);
@@ -1477,14 +994,11 @@ namespace CXX
<< "#define " << guard << endl
<< endl;
- {
- // Set auto-indentation.
- //
- Indentation::Clip<Indentation::CXX, WideChar> clip (hxx_impl);
-
- hxx_impl << "#include " << ctx.process_include_path (hxx_name)
- << endl << endl;
+ hxx_impl << "#include " << ctx.process_include_path (hxx_name)
+ << endl << endl;
+ {
+ ind_filter ind (hxx_impl);
generate_impl_header (ctx);
}
@@ -1504,14 +1018,13 @@ namespace CXX
&ixx_expr,
&hxx_impl_expr);
- // Set auto-indentation.
- //
- Indentation::Clip<Indentation::CXX, WideChar> clip (cxx_impl);
-
cxx_impl << "#include " << ctx.process_include_path (hxx_impl_name)
<< endl << endl;
- generate_impl_source (ctx);
+ {
+ ind_filter ind (cxx_impl);
+ generate_impl_source (ctx);
+ }
}
// CXX driver
@@ -1527,17 +1040,16 @@ namespace CXX
&ixx_expr,
&hxx_impl_expr);
- // Set auto-indentation.
- //
- Indentation::Clip<Indentation::CXX, WideChar> clip (cxx_driver);
-
cxx_driver << "#include " << ctx.process_include_path (hxx_impl_name)
<< endl << endl;
- generate_driver_source (ctx);
+ {
+ ind_filter ind (cxx_driver);
+ generate_driver_source (ctx);
+ }
}
- return sloc;
+ return sloc_total;
}
catch (UnrepresentableCharacter const& e)
{
@@ -1569,18 +1081,18 @@ namespace CXX
throw Failed ();
}
- catch (BackendElements::Regex::Format<Char> const& e)
+ catch (cutl::re::format const& e)
{
wcerr << "error: invalid regex: '" <<
- e.expression ().c_str () << "': " <<
+ e.regex ().c_str () << "': " <<
e.description ().c_str () << endl;
throw Failed ();
}
- catch (BackendElements::Regex::Format<WideChar> const& e)
+ catch (cutl::re::wformat const& e)
{
wcerr << "error: invalid regex: '" <<
- e.expression () << "': " << e.description () << endl;
+ e.regex () << "': " << e.description ().c_str () << endl;
throw Failed ();
}
diff --git a/xsd/xsd/cxx/parser/generator.hxx b/xsd/xsd/cxx/parser/generator.hxx
index eaa1ecd..784ca9d 100644
--- a/xsd/xsd/cxx/parser/generator.hxx
+++ b/xsd/xsd/cxx/parser/generator.hxx
@@ -1,50 +1,38 @@
// file : xsd/cxx/parser/generator.hxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#ifndef CXX_PARSER_GENERATOR_HXX
#define CXX_PARSER_GENERATOR_HXX
-#include <cult/types.hxx>
-
-#include <cult/containers/vector.hxx>
-
-#include <cult/cli/options.hxx>
-#include <cult/cli/options-spec.hxx>
-
#include <xsd-frontend/semantic-graph/elements.hxx> // Path
#include <xsd-frontend/semantic-graph/schema.hxx>
#include <xsd.hxx>
+#include <types.hxx>
#include <cxx/literal-map.hxx>
-#include <cxx/parser/cli.hxx>
+#include <cxx/parser/options.hxx>
namespace CXX
{
namespace Parser
{
- using namespace Cult::Types;
-
class Generator
{
public:
- static Void
+ static void
usage ();
- static CLI::OptionsSpec
- options_spec ();
-
struct Failed {};
- static UnsignedLong
- generate (CLI::Options const& options,
+ static size_t
+ generate (options const&,
XSDFrontend::SemanticGraph::Schema&,
XSDFrontend::SemanticGraph::Path const& file,
- Boolean file_per_type,
+ bool file_per_type,
StringLiteralMap const&,
- Boolean gen_driver,
+ bool gen_driver,
const WarningSet& disabled_warnings,
FileList& file_list,
AutoUnlinks& unlinks);
diff --git a/xsd/xsd/cxx/parser/impl-header.cxx b/xsd/xsd/cxx/parser/impl-header.cxx
index ff635f1..a3d47a4 100644
--- a/xsd/xsd/cxx/parser/impl-header.cxx
+++ b/xsd/xsd/cxx/parser/impl-header.cxx
@@ -1,6 +1,5 @@
// file : xsd/cxx/parser/impl-header.cxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#include <cxx/parser/impl-header.hxx>
@@ -21,7 +20,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& e)
{
String const& name (eimpl (e));
@@ -51,7 +50,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& l)
{
String const& name (eimpl (l));
@@ -98,7 +97,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& u)
{
String const& name (eimpl (u));
@@ -130,7 +129,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& m)
{
if (skip (m))
@@ -161,7 +160,7 @@ namespace CXX
names_parser_callback_ >> parser_callback_;
}
- virtual Void
+ virtual void
traverse (Type& c)
{
String const& name (eimpl (c));
@@ -202,12 +201,12 @@ namespace CXX
};
}
- Void
+ void
generate_impl_header (Context& ctx)
{
Traversal::Schema schema;
- Traversal::Sources sources;
+ Sources sources;
Includes includes (ctx, Includes::impl_header);
Traversal::Names schema_names;
diff --git a/xsd/xsd/cxx/parser/impl-header.hxx b/xsd/xsd/cxx/parser/impl-header.hxx
index dd63e52..273201b 100644
--- a/xsd/xsd/cxx/parser/impl-header.hxx
+++ b/xsd/xsd/cxx/parser/impl-header.hxx
@@ -1,6 +1,5 @@
// file : xsd/cxx/parser/impl-header.hxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#ifndef CXX_PARSER_IMPL_HEADER_HXX
@@ -12,7 +11,7 @@ namespace CXX
{
namespace Parser
{
- Void
+ void
generate_impl_header (Context&);
}
}
diff --git a/xsd/xsd/cxx/parser/impl-source.cxx b/xsd/xsd/cxx/parser/impl-source.cxx
index b951f6a..ad85f81 100644
--- a/xsd/xsd/cxx/parser/impl-source.cxx
+++ b/xsd/xsd/cxx/parser/impl-source.cxx
@@ -1,6 +1,5 @@
// file : xsd/cxx/parser/impl-source.cxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#include <cxx/parser/impl-source.hxx>
@@ -22,7 +21,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& e)
{
String const& name (eimpl (e));
@@ -57,7 +56,7 @@ namespace CXX
os << arg_type (base) << " v (" << post_name (base) << " ());"
<< endl;
- if (options.value<CLI::generate_print_impl> ())
+ if (options.generate_print_impl ())
{
PrintCall t (*this, e.name (), "v");
t.dispatch (base);
@@ -91,7 +90,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& l)
{
String const& name (eimpl (l));
@@ -126,7 +125,7 @@ namespace CXX
if (arg != L"void")
{
- if (options.value<CLI::generate_print_impl> ())
+ if (options.generate_print_impl ())
{
PrintCall t (*this, type.name (), item);
t.dispatch (type);
@@ -164,7 +163,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& u)
{
String const& name (eimpl (u));
@@ -186,7 +185,7 @@ namespace CXX
<< "_characters (const " << string_type << "& s)"
<< "{";
- if (options.value<CLI::generate_print_impl> ())
+ if (options.generate_print_impl ())
os << cout_inst << " << " << strlit (u.name () + L": ") <<
" << s << std::endl;";
else
@@ -221,7 +220,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& m)
{
if (skip (m))
@@ -244,7 +243,7 @@ namespace CXX
if (arg != L"void")
{
- if (options.value<CLI::generate_print_impl> ())
+ if (options.generate_print_impl ())
{
PrintCall t (*this, m.name (), name);
t.dispatch (m.type ());
@@ -268,12 +267,12 @@ namespace CXX
names_parser_callback_ >> parser_callback_;
}
- virtual Void
+ virtual void
traverse (Type& c)
{
String const& name (eimpl (c));
- Boolean restriction (restriction_p (c));
+ bool restriction (restriction_p (c));
os << "// " << name << endl
<< "//" << endl
@@ -314,7 +313,7 @@ namespace CXX
os << arg_type (base) << " v (" << post_name (base) << " ());"
<< endl;
- if (options.value<CLI::generate_print_impl> ())
+ if (options.generate_print_impl ())
{
PrintCall t (*this, c.name (), "v");
t.dispatch (base);
@@ -354,15 +353,15 @@ namespace CXX
};
}
- Void
+ void
generate_impl_source (Context& ctx)
{
- if (ctx.options.value<CLI::generate_print_impl> ())
+ if (ctx.options.generate_print_impl ())
ctx.os << "#include <iostream>" << endl
<< endl;
Traversal::Schema schema;
- Traversal::Sources sources;
+ Sources sources;
Traversal::Names schema_names;
Namespace ns (ctx);
Traversal::Names names;
diff --git a/xsd/xsd/cxx/parser/impl-source.hxx b/xsd/xsd/cxx/parser/impl-source.hxx
index 0d60162..b6f9b3d 100644
--- a/xsd/xsd/cxx/parser/impl-source.hxx
+++ b/xsd/xsd/cxx/parser/impl-source.hxx
@@ -1,6 +1,5 @@
// file : xsd/cxx/parser/impl-source.hxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#ifndef CXX_PARSER_IMPL_SOURCE_HXX
@@ -12,7 +11,7 @@ namespace CXX
{
namespace Parser
{
- Void
+ void
generate_impl_source (Context&);
}
}
diff --git a/xsd/xsd/cxx/parser/name-processor.cxx b/xsd/xsd/cxx/parser/name-processor.cxx
index d323187..219a3c9 100644
--- a/xsd/xsd/cxx/parser/name-processor.cxx
+++ b/xsd/xsd/cxx/parser/name-processor.cxx
@@ -1,66 +1,47 @@
// file : xsd/cxx/parser/name-processor.cxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2006-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2006-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+#include <set>
+#include <map>
+#include <sstream>
+#include <iostream>
+
#include <cxx/parser/name-processor.hxx>
#include <xsd-frontend/semantic-graph.hxx>
#include <xsd-frontend/traversal.hxx>
-#include <cult/containers/set.hxx>
-#include <sstream>
-#include <iostream>
+using namespace std;
namespace CXX
{
namespace Parser
{
- NameProcessor::
- NameProcessor ()
- {
- // Dummy ctor, helps with long symbols on HP-UX.
- }
-
namespace
{
//
//
- typedef Cult::Containers::Set<String> NameSet;
+ typedef set<String> NameSet;
class Context: public CXX::Context
{
public:
- Context (CLI::Options const& ops,
+ Context (Parser::options const& ops,
SemanticGraph::Schema& root,
SemanticGraph::Path const& path,
StringLiteralMap const* map)
- : CXX::Context (std::wcerr,
- root,
- path,
- map,
- ops.value<CLI::char_type> (),
- ops.value<CLI::char_encoding> (),
- ops.value<CLI::include_with_brackets> (),
- ops.value<CLI::include_prefix> (),
- ops.value<CLI::export_symbol> (),
- ops.value<CLI::namespace_map> (),
- ops.value<CLI::namespace_regex> (),
- ops.value<CLI::namespace_regex_trace> (),
- ops.value<CLI::include_regex> (),
- ops.value<CLI::include_regex_trace> (),
- ops.value<CLI::generate_inline> (),
- ops.value<CLI::reserved_name> ()),
- skel_suffix_ (ops.value<CLI::skel_type_suffix> ()),
- impl_suffix_ (ops.value<CLI::impl_type_suffix> ()),
- impl (ops.value<CLI::generate_noop_impl> () ||
- ops.value<CLI::generate_print_impl> () ||
- ops.value<CLI::generate_test_driver> ()),
+ : CXX::Context (std::wcerr, root, path, ops, map),
+ skel_suffix_ (ops.skel_type_suffix ()),
+ impl_suffix_ (ops.impl_type_suffix ()),
+ impl (ops.generate_noop_impl () ||
+ ops.generate_print_impl () ||
+ ops.generate_test_driver ()),
skel_suffix (skel_suffix_),
impl_suffix (impl_suffix_),
global_type_names (global_type_names_),
- polymorphic (ops.value<CLI::generate_polymorphic> ())
+ polymorphic (ops.generate_polymorphic ())
{
}
@@ -82,7 +63,7 @@ namespace CXX
String base_name (escape (n));
String name (base_name);
- for (UnsignedLong i (1); set.find (name) != set.end (); ++i)
+ for (size_t i (1); set.find (name) != set.end (); ++i)
{
std::wostringstream os;
os << i;
@@ -97,16 +78,16 @@ namespace CXX
String const skel_suffix_;
String const impl_suffix_;
- Cult::Containers::Map<String, NameSet> global_type_names_;
+ map<String, NameSet> global_type_names_;
public:
- Boolean const impl;
+ bool const impl;
String const& skel_suffix;
String const& impl_suffix;
- Cult::Containers::Map<String, NameSet>& global_type_names;
+ map<String, NameSet>& global_type_names;
- Boolean polymorphic;
+ bool polymorphic;
};
@@ -119,7 +100,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& m)
{
if (Parser::Context::skip (m))
@@ -139,7 +120,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& m)
{
if (Parser::Context::skip (m))
@@ -156,9 +137,6 @@ namespace CXX
!m.type ().context ().count ("anonymous"))
{
m.context ().set (
- "member-cache", find_name (base + L"_parser_cache_", set_));
-
- m.context ().set (
"member-map", find_name (base + L"_parser_map_", set_));
m.context ().set (
@@ -245,7 +223,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& m)
{
if (Parser::Context::skip (m))
@@ -282,17 +260,17 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& m)
{
if (Parser::Context::skip (m))
return;
- Boolean poly (polymorphic &&
+ bool poly (polymorphic &&
m.is_a<SemanticGraph::Element> () &&
!m.type ().context ().count ("anonymous"));
- String parser, member, member_cache, member_map, member_map_impl;
+ String parser, member, member_map, member_map_impl;
try
{
@@ -306,7 +284,6 @@ namespace CXX
if (poly)
{
- member_cache = bm.context ().get<String> ("member-cache");
member_map = bm.context ().get<String> ("member-map");
member_map_impl = bm.context ().get<String> ("member-map-impl");
}
@@ -322,7 +299,6 @@ namespace CXX
if (poly)
{
- member_cache = find_name (base + L"_parser_cache_", set_);
member_map = find_name (base + L"_parser_map_", set_);
member_map_impl = find_name (base + L"_parser_map_impl_", set_);
}
@@ -333,7 +309,6 @@ namespace CXX
if (poly)
{
- m.context ().set ("member-cache", member_cache);
m.context ().set ("member-map", member_map);
m.context ().set ("member-map-impl", member_map_impl);
}
@@ -349,7 +324,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& c)
{
SemanticGraph::Context& cc (c.context ());
@@ -371,7 +346,7 @@ namespace CXX
// inheriting by restriction in which case we need to have
// the same names as our base.
//
- Boolean restriction (false);
+ bool restriction (false);
if (c.inherits_p ())
{
@@ -464,7 +439,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Type& t)
{
SemanticGraph::Context& c (t.context ());
@@ -533,7 +508,7 @@ namespace CXX
String base_name (escape (L"post_" + n));
String post (base_name);
- for (UnsignedLong i (1); set.find (post) != set.end (); ++i)
+ for (size_t i (1); set.find (post) != set.end (); ++i)
{
std::wostringstream os;
os << i;
@@ -556,7 +531,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& ns)
{
NameSet& type_set (global_type_names[ns.name ()]);
@@ -634,7 +609,7 @@ namespace CXX
// anyType & anySimpleType.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::AnyType& t)
{
t.context ().set ("name", make_skel_name ("any_type"));
@@ -642,7 +617,7 @@ namespace CXX
t.context ().set ("post", String ("post_any_type"));
}
- virtual Void
+ virtual void
traverse (SemanticGraph::AnySimpleType& t)
{
t.context ().set ("name", make_skel_name ("any_simple_type"));
@@ -652,7 +627,7 @@ namespace CXX
// Boolean.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Boolean& t)
{
t.context ().set ("name", make_skel_name ("boolean"));
@@ -662,7 +637,7 @@ namespace CXX
// Integral types.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Byte& t)
{
t.context ().set ("name", make_skel_name ("byte"));
@@ -670,7 +645,7 @@ namespace CXX
t.context ().set ("post", String ("post_byte"));
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::UnsignedByte& t)
{
t.context ().set ("name", make_skel_name ("unsigned_byte"));
@@ -678,7 +653,7 @@ namespace CXX
t.context ().set ("post", String ("post_unsigned_byte"));
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Short& t)
{
t.context ().set ("name", make_skel_name ("short"));
@@ -686,7 +661,7 @@ namespace CXX
t.context ().set ("post", String ("post_short"));
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::UnsignedShort& t)
{
t.context ().set ("name", make_skel_name ("unsigned_short"));
@@ -694,7 +669,7 @@ namespace CXX
t.context ().set ("post", String ("post_unsigned_short"));
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Int& t)
{
t.context ().set ("name", make_skel_name ("int"));
@@ -702,7 +677,7 @@ namespace CXX
t.context ().set ("post", String ("post_int"));
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::UnsignedInt& t)
{
t.context ().set ("name", make_skel_name ("unsigned_int"));
@@ -710,7 +685,7 @@ namespace CXX
t.context ().set ("post", String ("post_unsigned_int"));
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Long& t)
{
t.context ().set ("name", make_skel_name ("long"));
@@ -718,7 +693,7 @@ namespace CXX
t.context ().set ("post", String ("post_long"));
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::UnsignedLong& t)
{
t.context ().set ("name", make_skel_name ("unsigned_long"));
@@ -726,7 +701,7 @@ namespace CXX
t.context ().set ("post", String ("post_unsigned_long"));
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Integer& t)
{
t.context ().set ("name", make_skel_name ("integer"));
@@ -734,7 +709,7 @@ namespace CXX
t.context ().set ("post", String ("post_integer"));
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NonPositiveInteger& t)
{
t.context ().set ("name", make_skel_name ("non_positive_integer"));
@@ -742,7 +717,7 @@ namespace CXX
t.context ().set ("post", String ("post_non_positive_integer"));
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NonNegativeInteger& t)
{
t.context ().set ("name", make_skel_name ("non_negative_integer"));
@@ -750,7 +725,7 @@ namespace CXX
t.context ().set ("post", String ("post_non_negative_integer"));
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::PositiveInteger& t)
{
t.context ().set ("name", make_skel_name ("positive_integer"));
@@ -758,7 +733,7 @@ namespace CXX
t.context ().set ("post", String ("post_positive_integer"));
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NegativeInteger& t)
{
t.context ().set ("name", make_skel_name ("negative_integer"));
@@ -768,7 +743,7 @@ namespace CXX
// Floats.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Float& t)
{
t.context ().set ("name", make_skel_name ("float"));
@@ -776,7 +751,7 @@ namespace CXX
t.context ().set ("post", String ("post_float"));
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Double& t)
{
t.context ().set ("name", make_skel_name ("double"));
@@ -784,7 +759,7 @@ namespace CXX
t.context ().set ("post", String ("post_double"));
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Decimal& t)
{
t.context ().set ("name", make_skel_name ("decimal"));
@@ -794,7 +769,7 @@ namespace CXX
// Strings.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::String& t)
{
t.context ().set ("name", make_skel_name ("string"));
@@ -802,7 +777,7 @@ namespace CXX
t.context ().set ("post", String ("post_string"));
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NormalizedString& t)
{
t.context ().set ("name", make_skel_name ("normalized_string"));
@@ -810,7 +785,7 @@ namespace CXX
t.context ().set ("post", String ("post_normalized_string"));
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Token& t)
{
t.context ().set ("name", make_skel_name ("token"));
@@ -818,7 +793,7 @@ namespace CXX
t.context ().set ("post", String ("post_token"));
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NameToken& t)
{
t.context ().set ("name", make_skel_name ("nmtoken"));
@@ -826,7 +801,7 @@ namespace CXX
t.context ().set ("post", String ("post_nmtoken"));
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NameTokens& t)
{
t.context ().set ("name", make_skel_name ("nmtokens"));
@@ -834,7 +809,7 @@ namespace CXX
t.context ().set ("post", String ("post_nmtokens"));
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Name& t)
{
t.context ().set ("name", make_skel_name ("name"));
@@ -842,7 +817,7 @@ namespace CXX
t.context ().set ("post", String ("post_name"));
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NCName& t)
{
t.context ().set ("name", make_skel_name ("ncname"));
@@ -850,7 +825,7 @@ namespace CXX
t.context ().set ("post", String ("post_ncname"));
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Language& t)
{
t.context ().set ("name", make_skel_name ("language"));
@@ -861,7 +836,7 @@ namespace CXX
// Qualified name.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::QName& t)
{
t.context ().set ("name", make_skel_name ("qname"));
@@ -872,7 +847,7 @@ namespace CXX
// ID/IDREF.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Id& t)
{
t.context ().set ("name", make_skel_name ("id"));
@@ -880,7 +855,7 @@ namespace CXX
t.context ().set ("post", String ("post_id"));
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::IdRef& t)
{
t.context ().set ("name", make_skel_name ("idref"));
@@ -888,7 +863,7 @@ namespace CXX
t.context ().set ("post", String ("post_idref"));
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::IdRefs& t)
{
t.context ().set ("name", make_skel_name ("idrefs"));
@@ -898,7 +873,7 @@ namespace CXX
// URI.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::AnyURI& t)
{
t.context ().set ("name", make_skel_name ("uri"));
@@ -908,7 +883,7 @@ namespace CXX
// Binary.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Base64Binary& t)
{
t.context ().set ("name", make_skel_name ("base64_binary"));
@@ -916,7 +891,7 @@ namespace CXX
t.context ().set ("post", String ("post_base64_binary"));
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::HexBinary& t)
{
t.context ().set ("name", make_skel_name ("hex_binary"));
@@ -927,7 +902,7 @@ namespace CXX
// Date/time.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Date& t)
{
t.context ().set ("name", make_skel_name ("date"));
@@ -935,7 +910,7 @@ namespace CXX
t.context ().set ("post", String ("post_date"));
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::DateTime& t)
{
t.context ().set ("name", make_skel_name ("date_time"));
@@ -943,7 +918,7 @@ namespace CXX
t.context ().set ("post", String ("post_date_time"));
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Duration& t)
{
t.context ().set ("name", make_skel_name ("duration"));
@@ -951,7 +926,7 @@ namespace CXX
t.context ().set ("post", String ("post_duration"));
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Day& t)
{
t.context ().set ("name", make_skel_name ("gday"));
@@ -959,7 +934,7 @@ namespace CXX
t.context ().set ("post", String ("post_gday"));
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Month& t)
{
t.context ().set ("name", make_skel_name ("gmonth"));
@@ -967,7 +942,7 @@ namespace CXX
t.context ().set ("post", String ("post_gmonth"));
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::MonthDay& t)
{
t.context ().set ("name", make_skel_name ("gmonth_day"));
@@ -975,7 +950,7 @@ namespace CXX
t.context ().set ("post", String ("post_gmonth_day"));
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Year& t)
{
t.context ().set ("name", make_skel_name ("gyear"));
@@ -983,7 +958,7 @@ namespace CXX
t.context ().set ("post", String ("post_gyear"));
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::YearMonth& t)
{
t.context ().set ("name", make_skel_name ("gyear_month"));
@@ -991,7 +966,7 @@ namespace CXX
t.context ().set ("post", String ("post_gyear_month"));
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Time& t)
{
t.context ().set ("name", make_skel_name ("time"));
@@ -1001,7 +976,7 @@ namespace CXX
// Entity.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Entity& t)
{
t.context ().set ("name", make_skel_name ("entity"));
@@ -1009,7 +984,7 @@ namespace CXX
t.context ().set ("post", String ("post_entity"));
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Entities& t)
{
t.context ().set ("name", make_skel_name ("entities"));
@@ -1038,7 +1013,7 @@ namespace CXX
Traversal::Includes,
Traversal::Imports
{
- virtual Void
+ virtual void
traverse (SemanticGraph::Sources& sr)
{
SemanticGraph::Schema& s (sr.schema ());
@@ -1050,7 +1025,7 @@ namespace CXX
}
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Includes& i)
{
SemanticGraph::Schema& s (i.schema ());
@@ -1062,7 +1037,7 @@ namespace CXX
}
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Imports& i)
{
SemanticGraph::Schema& s (i.schema ());
@@ -1080,7 +1055,7 @@ namespace CXX
//
struct Implies: Traversal::Implies
{
- virtual Void
+ virtual void
traverse (SemanticGraph::Implies& i)
{
SemanticGraph::Schema& s (i.schema ());
@@ -1093,8 +1068,8 @@ namespace CXX
}
};
- Void
- process_impl (CLI::Options const& ops,
+ void
+ process_impl (options const& ops,
SemanticGraph::Schema& tu,
SemanticGraph::Path const& file,
StringLiteralMap const& map)
@@ -1169,7 +1144,7 @@ namespace CXX
//
{
Traversal::Schema schema;
- Traversal::Sources sources;
+ Sources sources;
schema >> sources >> schema;
@@ -1189,8 +1164,8 @@ namespace CXX
}
}
- Void NameProcessor::
- process (CLI::Options const& ops,
+ void NameProcessor::
+ process (options const& ops,
SemanticGraph::Schema& tu,
SemanticGraph::Path const& file,
StringLiteralMap const& map)
diff --git a/xsd/xsd/cxx/parser/name-processor.hxx b/xsd/xsd/cxx/parser/name-processor.hxx
index 5c28371..0460ea4 100644
--- a/xsd/xsd/cxx/parser/name-processor.hxx
+++ b/xsd/xsd/cxx/parser/name-processor.hxx
@@ -1,6 +1,5 @@
// file : xsd/cxx/parser/name-processor.hxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2006-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2006-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#ifndef CXX_PARSER_NAME_PROCESSOR_HXX
@@ -8,22 +7,20 @@
#include <xsd-frontend/semantic-graph.hxx>
+#include <types.hxx>
+
#include <cxx/elements.hxx>
-#include <cxx/parser/cli.hxx>
+#include <cxx/parser/options.hxx>
namespace CXX
{
namespace Parser
{
- using namespace Cult::Types;
-
class NameProcessor
{
public:
- NameProcessor (); // Dummy ctor, helps with long symbols on HP-UX.
-
- Void
- process (CLI::Options const& ops,
+ void
+ process (options const&,
XSDFrontend::SemanticGraph::Schema&,
XSDFrontend::SemanticGraph::Path const& file,
StringLiteralMap const& map);
diff --git a/xsd/xsd/cxx/parser/options.cli b/xsd/xsd/cxx/parser/options.cli
new file mode 100644
index 0000000..227bb51
--- /dev/null
+++ b/xsd/xsd/cxx/parser/options.cli
@@ -0,0 +1,148 @@
+// file : xsd/cxx/parser/options.cli
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+include <cstddef>; // std::size_t
+
+include <types.hxx>; // NarrowString, NarrowStrings
+
+include <cxx/options.cli>;
+
+namespace CXX
+{
+ namespace Parser
+ {
+ class options: CXX::options
+ {
+ NarrowStrings --type-map
+ {
+ "<mapfile>",
+ "Read XML Schema to C++ type mapping information from <mapfile>.
+ Repeat this option to specify several type maps. Type maps are
+ considered in order of appearance and the first match is used. By
+ default all user-defined types are mapped to \cb{void}. See the
+ TYPE MAP section below for more information."
+ };
+
+ NarrowString --xml-parser = "xerces"
+ {
+ "<parser>",
+ "Use <parser> as the underlying XML parser. Valid values are
+ \cb{xerces} for Xerces-C++ (default) and \cb{expat} for Expat."
+ };
+
+ // Features.
+ //
+ bool --generate-validation
+ {
+ "Generate validation code. The validation code (\"perfect parser\")
+ ensures that instance documents conform to the schema. Validation
+ code is generated by default when the selected underlying XML parser
+ is non-validating (\cb{expat})."
+ };
+
+ bool --suppress-validation
+ {
+ "Suppress the generation of validation code. Validation is suppressed
+ by default when the selected underlying XML parser is validating
+ (\cb{xerces})."
+ };
+
+ bool --generate-polymorphic
+ {
+ "Generate polymorphism-aware code. Specify this option if you use
+ substitution groups or \cb{xsi:type}."
+ };
+
+ bool --generate-noop-impl
+ {
+ "Generate a sample parser implementation that does nothing (no
+ operation). The sample implementation can then be filled with
+ the application-specific code. For an input file in the form
+ \cb{name.xsd} this option triggers the generation of two
+ additional C++ files in the form: \cb{name-pimpl.hxx} (parser
+ implementation header file) and \cb{name-pimpl.cxx} (parser
+ implementation source file)."
+ };
+
+ bool --generate-print-impl
+ {
+ "Generate a sample parser implementation that prints the XML data
+ to \c{STDOUT}. For an input file in the form \cb{name.xsd} this
+ option triggers the generation of two additional C++ files in the
+ form: \cb{name-pimpl.hxx} (parser implementation header file) and
+ \cb{name-pimpl.cxx} (parser implementation source file)."
+ };
+
+ bool --generate-test-driver
+ {
+ "Generate a test driver for the sample parser implementation. For an
+ input file in the form \cb{name.xsd} this option triggers the
+ generation of an additional C++ file in the form
+ \cb{name-driver.cxx}."
+ };
+
+ bool --force-overwrite
+ {
+ "Force overwriting of the existing implementation and test driver
+ files. Use this option only if you do not mind loosing the changes
+ you have made in the sample implementation or test driver files."
+ };
+
+ // Root element.
+ //
+ bool --root-element-first
+ {
+ "Indicate that the first global element is the document root. This
+ information is used to generate the test driver for the sample
+ implementation."
+ };
+
+ bool --root-element-last
+ {
+ "Indicate that the last global element is the document root. This
+ information is used to generate the test driver for the sample
+ implementation."
+ };
+
+ NarrowString --root-element
+ {
+ "<element>",
+ "Indicate that <element> is the document root. This information is
+ used to generate the test driver for the sample implementation."
+ };
+
+ // Suffixes.
+ //
+ NarrowString --skel-type-suffix = "_pskel"
+ {
+ "<suffix>",
+ "Use the provided <suffix> instead of the default \cb{_pskel} to
+ construct the names of the generated parser skeletons."
+ };
+
+ NarrowString --skel-file-suffix = "-pskel"
+ {
+ "<suffix>",
+ "Use the provided <suffix> instead of the default \cb{-pskel} to
+ construct the names of the generated parser skeleton files."
+ };
+
+ NarrowString --impl-type-suffix = "_pimpl"
+ {
+ "<suffix>",
+ "Use the provided <suffix> instead of the default \cb{_pimpl} to
+ construct the names of the parser implementations for the built-in
+ XML Schema types as well as sample parser implementations."
+ };
+
+ NarrowString --impl-file-suffix = "-pimpl"
+ {
+ "<suffix>",
+ "Use the provided <suffix> instead of the default \cb{-pimpl} to
+ construct the names of the generated sample parser implementation
+ files."
+ };
+ };
+ }
+}
diff --git a/xsd/xsd/cxx/parser/options.cxx b/xsd/xsd/cxx/parser/options.cxx
new file mode 100644
index 0000000..6f18446
--- /dev/null
+++ b/xsd/xsd/cxx/parser/options.cxx
@@ -0,0 +1,581 @@
+// This code was generated by CLI, a command line interface
+// compiler for C++.
+//
+
+// Begin prologue.
+//
+#include <options-parser.hxx>
+//
+// End prologue.
+
+#include <cxx/parser/options.hxx>
+
+#include <map>
+#include <set>
+#include <string>
+#include <vector>
+#include <ostream>
+#include <sstream>
+
+namespace cli
+{
+ template <typename X>
+ struct parser
+ {
+ static void
+ parse (X& x, bool& xs, scanner& s)
+ {
+ std::string o (s.next ());
+
+ if (s.more ())
+ {
+ std::string v (s.next ());
+ std::istringstream is (v);
+ if (!(is >> x && is.eof ()))
+ throw invalid_value (o, v);
+ }
+ else
+ throw missing_value (o);
+
+ xs = true;
+ }
+ };
+
+ template <>
+ struct parser<bool>
+ {
+ static void
+ parse (bool& x, scanner& s)
+ {
+ s.next ();
+ x = true;
+ }
+ };
+
+ template <>
+ struct parser<std::string>
+ {
+ static void
+ parse (std::string& x, bool& xs, scanner& s)
+ {
+ const char* o (s.next ());
+
+ if (s.more ())
+ x = s.next ();
+ else
+ throw missing_value (o);
+
+ xs = true;
+ }
+ };
+
+ template <typename X>
+ struct parser<std::vector<X> >
+ {
+ static void
+ parse (std::vector<X>& c, bool& xs, scanner& s)
+ {
+ X x;
+ bool dummy;
+ parser<X>::parse (x, dummy, s);
+ c.push_back (x);
+ xs = true;
+ }
+ };
+
+ template <typename X>
+ struct parser<std::set<X> >
+ {
+ static void
+ parse (std::set<X>& c, bool& xs, scanner& s)
+ {
+ X x;
+ bool dummy;
+ parser<X>::parse (x, dummy, s);
+ c.insert (x);
+ xs = true;
+ }
+ };
+
+ template <typename K, typename V>
+ struct parser<std::map<K, V> >
+ {
+ static void
+ parse (std::map<K, V>& m, bool& xs, scanner& s)
+ {
+ std::string o (s.next ());
+
+ if (s.more ())
+ {
+ std::string ov (s.next ());
+ std::string::size_type p = ov.find ('=');
+
+ if (p == std::string::npos)
+ {
+ K k = K ();
+
+ if (!ov.empty ())
+ {
+ std::istringstream ks (ov);
+
+ if (!(ks >> k && ks.eof ()))
+ throw invalid_value (o, ov);
+ }
+
+ m[k] = V ();
+ }
+ else
+ {
+ K k = K ();
+ V v = V ();
+ std::string kstr (ov, 0, p);
+ std::string vstr (ov, p + 1);
+
+ if (!kstr.empty ())
+ {
+ std::istringstream ks (kstr);
+
+ if (!(ks >> k && ks.eof ()))
+ throw invalid_value (o, ov);
+ }
+
+ if (!vstr.empty ())
+ {
+ std::istringstream vs (vstr);
+
+ if (!(vs >> v && vs.eof ()))
+ throw invalid_value (o, ov);
+ }
+
+ m[k] = v;
+ }
+ }
+ else
+ throw missing_value (o);
+
+ xs = true;
+ }
+ };
+
+ template <typename X, typename T, T X::*M>
+ void
+ thunk (X& x, scanner& s)
+ {
+ parser<T>::parse (x.*M, s);
+ }
+
+ template <typename X, typename T, T X::*M, bool X::*S>
+ void
+ thunk (X& x, scanner& s)
+ {
+ parser<T>::parse (x.*M, x.*S, s);
+ }
+}
+
+#include <map>
+#include <cstring>
+
+namespace CXX
+{
+ namespace Parser
+ {
+ // options
+ //
+
+ options::
+ options ()
+ : type_map_ (),
+ type_map_specified_ (false),
+ xml_parser_ ("xerces"),
+ xml_parser_specified_ (false),
+ generate_validation_ (),
+ suppress_validation_ (),
+ generate_polymorphic_ (),
+ generate_noop_impl_ (),
+ generate_print_impl_ (),
+ generate_test_driver_ (),
+ force_overwrite_ (),
+ root_element_first_ (),
+ root_element_last_ (),
+ root_element_ (),
+ root_element_specified_ (false),
+ skel_type_suffix_ ("_pskel"),
+ skel_type_suffix_specified_ (false),
+ skel_file_suffix_ ("-pskel"),
+ skel_file_suffix_specified_ (false),
+ impl_type_suffix_ ("_pimpl"),
+ impl_type_suffix_specified_ (false),
+ impl_file_suffix_ ("-pimpl"),
+ impl_file_suffix_specified_ (false)
+ {
+ }
+
+ options::
+ options (int& argc,
+ char** argv,
+ bool erase,
+ ::cli::unknown_mode opt,
+ ::cli::unknown_mode arg)
+ : type_map_ (),
+ type_map_specified_ (false),
+ xml_parser_ ("xerces"),
+ xml_parser_specified_ (false),
+ generate_validation_ (),
+ suppress_validation_ (),
+ generate_polymorphic_ (),
+ generate_noop_impl_ (),
+ generate_print_impl_ (),
+ generate_test_driver_ (),
+ force_overwrite_ (),
+ root_element_first_ (),
+ root_element_last_ (),
+ root_element_ (),
+ root_element_specified_ (false),
+ skel_type_suffix_ ("_pskel"),
+ skel_type_suffix_specified_ (false),
+ skel_file_suffix_ ("-pskel"),
+ skel_file_suffix_specified_ (false),
+ impl_type_suffix_ ("_pimpl"),
+ impl_type_suffix_specified_ (false),
+ impl_file_suffix_ ("-pimpl"),
+ impl_file_suffix_specified_ (false)
+ {
+ ::cli::argv_scanner s (argc, argv, erase);
+ _parse (s, opt, arg);
+ }
+
+ options::
+ options (int start,
+ int& argc,
+ char** argv,
+ bool erase,
+ ::cli::unknown_mode opt,
+ ::cli::unknown_mode arg)
+ : type_map_ (),
+ type_map_specified_ (false),
+ xml_parser_ ("xerces"),
+ xml_parser_specified_ (false),
+ generate_validation_ (),
+ suppress_validation_ (),
+ generate_polymorphic_ (),
+ generate_noop_impl_ (),
+ generate_print_impl_ (),
+ generate_test_driver_ (),
+ force_overwrite_ (),
+ root_element_first_ (),
+ root_element_last_ (),
+ root_element_ (),
+ root_element_specified_ (false),
+ skel_type_suffix_ ("_pskel"),
+ skel_type_suffix_specified_ (false),
+ skel_file_suffix_ ("-pskel"),
+ skel_file_suffix_specified_ (false),
+ impl_type_suffix_ ("_pimpl"),
+ impl_type_suffix_specified_ (false),
+ impl_file_suffix_ ("-pimpl"),
+ impl_file_suffix_specified_ (false)
+ {
+ ::cli::argv_scanner s (start, argc, argv, erase);
+ _parse (s, opt, arg);
+ }
+
+ options::
+ options (int& argc,
+ char** argv,
+ int& end,
+ bool erase,
+ ::cli::unknown_mode opt,
+ ::cli::unknown_mode arg)
+ : type_map_ (),
+ type_map_specified_ (false),
+ xml_parser_ ("xerces"),
+ xml_parser_specified_ (false),
+ generate_validation_ (),
+ suppress_validation_ (),
+ generate_polymorphic_ (),
+ generate_noop_impl_ (),
+ generate_print_impl_ (),
+ generate_test_driver_ (),
+ force_overwrite_ (),
+ root_element_first_ (),
+ root_element_last_ (),
+ root_element_ (),
+ root_element_specified_ (false),
+ skel_type_suffix_ ("_pskel"),
+ skel_type_suffix_specified_ (false),
+ skel_file_suffix_ ("-pskel"),
+ skel_file_suffix_specified_ (false),
+ impl_type_suffix_ ("_pimpl"),
+ impl_type_suffix_specified_ (false),
+ impl_file_suffix_ ("-pimpl"),
+ impl_file_suffix_specified_ (false)
+ {
+ ::cli::argv_scanner s (argc, argv, erase);
+ _parse (s, opt, arg);
+ end = s.end ();
+ }
+
+ options::
+ options (int start,
+ int& argc,
+ char** argv,
+ int& end,
+ bool erase,
+ ::cli::unknown_mode opt,
+ ::cli::unknown_mode arg)
+ : type_map_ (),
+ type_map_specified_ (false),
+ xml_parser_ ("xerces"),
+ xml_parser_specified_ (false),
+ generate_validation_ (),
+ suppress_validation_ (),
+ generate_polymorphic_ (),
+ generate_noop_impl_ (),
+ generate_print_impl_ (),
+ generate_test_driver_ (),
+ force_overwrite_ (),
+ root_element_first_ (),
+ root_element_last_ (),
+ root_element_ (),
+ root_element_specified_ (false),
+ skel_type_suffix_ ("_pskel"),
+ skel_type_suffix_specified_ (false),
+ skel_file_suffix_ ("-pskel"),
+ skel_file_suffix_specified_ (false),
+ impl_type_suffix_ ("_pimpl"),
+ impl_type_suffix_specified_ (false),
+ impl_file_suffix_ ("-pimpl"),
+ impl_file_suffix_specified_ (false)
+ {
+ ::cli::argv_scanner s (start, argc, argv, erase);
+ _parse (s, opt, arg);
+ end = s.end ();
+ }
+
+ options::
+ options (::cli::scanner& s,
+ ::cli::unknown_mode opt,
+ ::cli::unknown_mode arg)
+ : type_map_ (),
+ type_map_specified_ (false),
+ xml_parser_ ("xerces"),
+ xml_parser_specified_ (false),
+ generate_validation_ (),
+ suppress_validation_ (),
+ generate_polymorphic_ (),
+ generate_noop_impl_ (),
+ generate_print_impl_ (),
+ generate_test_driver_ (),
+ force_overwrite_ (),
+ root_element_first_ (),
+ root_element_last_ (),
+ root_element_ (),
+ root_element_specified_ (false),
+ skel_type_suffix_ ("_pskel"),
+ skel_type_suffix_specified_ (false),
+ skel_file_suffix_ ("-pskel"),
+ skel_file_suffix_specified_ (false),
+ impl_type_suffix_ ("_pimpl"),
+ impl_type_suffix_specified_ (false),
+ impl_file_suffix_ ("-pimpl"),
+ impl_file_suffix_specified_ (false)
+ {
+ _parse (s, opt, arg);
+ }
+
+ void options::
+ print_usage (::std::wostream& os)
+ {
+ os << "--type-map <mapfile> Read XML Schema to C++ type mapping information" << ::std::endl
+ << " from <mapfile>." << ::std::endl;
+
+ os << "--xml-parser <parser> Use <parser> as the underlying XML parser." << ::std::endl;
+
+ os << "--generate-validation Generate validation code." << ::std::endl;
+
+ os << "--suppress-validation Suppress the generation of validation code." << ::std::endl;
+
+ os << "--generate-polymorphic Generate polymorphism-aware code." << ::std::endl;
+
+ os << "--generate-noop-impl Generate a sample parser implementation that does" << ::std::endl
+ << " nothing (no operation)." << ::std::endl;
+
+ os << "--generate-print-impl Generate a sample parser implementation that" << ::std::endl
+ << " prints the XML data to 'STDOUT'." << ::std::endl;
+
+ os << "--generate-test-driver Generate a test driver for the sample parser" << ::std::endl
+ << " implementation." << ::std::endl;
+
+ os << "--force-overwrite Force overwriting of the existing implementation" << ::std::endl
+ << " and test driver files." << ::std::endl;
+
+ os << "--root-element-first Indicate that the first global element is the" << ::std::endl
+ << " document root." << ::std::endl;
+
+ os << "--root-element-last Indicate that the last global element is the" << ::std::endl
+ << " document root." << ::std::endl;
+
+ os << "--root-element <element> Indicate that <element> is the document root." << ::std::endl;
+
+ os << "--skel-type-suffix <suffix> Use the provided <suffix> instead of the default" << ::std::endl
+ << " '_pskel' to construct the names of the generated" << ::std::endl
+ << " parser skeletons." << ::std::endl;
+
+ os << "--skel-file-suffix <suffix> Use the provided <suffix> instead of the default" << ::std::endl
+ << " '-pskel' to construct the names of the generated" << ::std::endl
+ << " parser skeleton files." << ::std::endl;
+
+ os << "--impl-type-suffix <suffix> Use the provided <suffix> instead of the default" << ::std::endl
+ << " '_pimpl' to construct the names of the parser" << ::std::endl
+ << " implementations for the built-in XML Schema types" << ::std::endl
+ << " as well as sample parser implementations." << ::std::endl;
+
+ os << "--impl-file-suffix <suffix> Use the provided <suffix> instead of the default" << ::std::endl
+ << " '-pimpl' to construct the names of the generated" << ::std::endl
+ << " sample parser implementation files." << ::std::endl;
+ }
+
+ typedef
+ std::map<std::string, void (*) (options&, ::cli::scanner&)>
+ _cli_options_map;
+
+ static _cli_options_map _cli_options_map_;
+
+ struct _cli_options_map_init
+ {
+ _cli_options_map_init ()
+ {
+ _cli_options_map_["--type-map"] =
+ &::cli::thunk< options, NarrowStrings, &options::type_map_,
+ &options::type_map_specified_ >;
+ _cli_options_map_["--xml-parser"] =
+ &::cli::thunk< options, NarrowString, &options::xml_parser_,
+ &options::xml_parser_specified_ >;
+ _cli_options_map_["--generate-validation"] =
+ &::cli::thunk< options, bool, &options::generate_validation_ >;
+ _cli_options_map_["--suppress-validation"] =
+ &::cli::thunk< options, bool, &options::suppress_validation_ >;
+ _cli_options_map_["--generate-polymorphic"] =
+ &::cli::thunk< options, bool, &options::generate_polymorphic_ >;
+ _cli_options_map_["--generate-noop-impl"] =
+ &::cli::thunk< options, bool, &options::generate_noop_impl_ >;
+ _cli_options_map_["--generate-print-impl"] =
+ &::cli::thunk< options, bool, &options::generate_print_impl_ >;
+ _cli_options_map_["--generate-test-driver"] =
+ &::cli::thunk< options, bool, &options::generate_test_driver_ >;
+ _cli_options_map_["--force-overwrite"] =
+ &::cli::thunk< options, bool, &options::force_overwrite_ >;
+ _cli_options_map_["--root-element-first"] =
+ &::cli::thunk< options, bool, &options::root_element_first_ >;
+ _cli_options_map_["--root-element-last"] =
+ &::cli::thunk< options, bool, &options::root_element_last_ >;
+ _cli_options_map_["--root-element"] =
+ &::cli::thunk< options, NarrowString, &options::root_element_,
+ &options::root_element_specified_ >;
+ _cli_options_map_["--skel-type-suffix"] =
+ &::cli::thunk< options, NarrowString, &options::skel_type_suffix_,
+ &options::skel_type_suffix_specified_ >;
+ _cli_options_map_["--skel-file-suffix"] =
+ &::cli::thunk< options, NarrowString, &options::skel_file_suffix_,
+ &options::skel_file_suffix_specified_ >;
+ _cli_options_map_["--impl-type-suffix"] =
+ &::cli::thunk< options, NarrowString, &options::impl_type_suffix_,
+ &options::impl_type_suffix_specified_ >;
+ _cli_options_map_["--impl-file-suffix"] =
+ &::cli::thunk< options, NarrowString, &options::impl_file_suffix_,
+ &options::impl_file_suffix_specified_ >;
+ }
+ };
+
+ static _cli_options_map_init _cli_options_map_init_;
+
+ bool options::
+ _parse (const char* o, ::cli::scanner& s)
+ {
+ _cli_options_map::const_iterator i (_cli_options_map_.find (o));
+
+ if (i != _cli_options_map_.end ())
+ {
+ (*(i->second)) (*this, s);
+ return true;
+ }
+
+ // options base
+ //
+ if (::CXX::options::_parse (o, s))
+ return true;
+
+ return false;
+ }
+
+ void options::
+ _parse (::cli::scanner& s,
+ ::cli::unknown_mode opt_mode,
+ ::cli::unknown_mode arg_mode)
+ {
+ bool opt = true;
+
+ while (s.more ())
+ {
+ const char* o = s.peek ();
+
+ if (std::strcmp (o, "--") == 0)
+ {
+ s.skip ();
+ opt = false;
+ continue;
+ }
+
+ if (opt && _parse (o, s));
+ else if (opt && std::strncmp (o, "-", 1) == 0 && o[1] != '\0')
+ {
+ switch (opt_mode)
+ {
+ case ::cli::unknown_mode::skip:
+ {
+ s.skip ();
+ continue;
+ }
+ case ::cli::unknown_mode::stop:
+ {
+ break;
+ }
+ case ::cli::unknown_mode::fail:
+ {
+ throw ::cli::unknown_option (o);
+ }
+ }
+
+ break;
+ }
+ else
+ {
+ switch (arg_mode)
+ {
+ case ::cli::unknown_mode::skip:
+ {
+ s.skip ();
+ continue;
+ }
+ case ::cli::unknown_mode::stop:
+ {
+ break;
+ }
+ case ::cli::unknown_mode::fail:
+ {
+ throw ::cli::unknown_argument (o);
+ }
+ }
+
+ break;
+ }
+ }
+ }
+ }
+}
+
+// Begin epilogue.
+//
+//
+// End epilogue.
+
diff --git a/xsd/xsd/cxx/parser/options.hxx b/xsd/xsd/cxx/parser/options.hxx
new file mode 100644
index 0000000..976f93b
--- /dev/null
+++ b/xsd/xsd/cxx/parser/options.hxx
@@ -0,0 +1,183 @@
+// This code was generated by CLI, a command line interface
+// compiler for C++.
+//
+
+#ifndef CXX_PARSER_OPTIONS_HXX
+#define CXX_PARSER_OPTIONS_HXX
+
+// Begin prologue.
+//
+//
+// End prologue.
+
+#include <cstddef>
+
+#include <types.hxx>
+
+#include <cxx/options.hxx>
+
+namespace CXX
+{
+ namespace Parser
+ {
+ class options: public ::CXX::options
+ {
+ public:
+ options (int& argc,
+ char** argv,
+ bool erase = false,
+ ::cli::unknown_mode option = ::cli::unknown_mode::fail,
+ ::cli::unknown_mode argument = ::cli::unknown_mode::stop);
+
+ options (int start,
+ int& argc,
+ char** argv,
+ bool erase = false,
+ ::cli::unknown_mode option = ::cli::unknown_mode::fail,
+ ::cli::unknown_mode argument = ::cli::unknown_mode::stop);
+
+ options (int& argc,
+ char** argv,
+ int& end,
+ bool erase = false,
+ ::cli::unknown_mode option = ::cli::unknown_mode::fail,
+ ::cli::unknown_mode argument = ::cli::unknown_mode::stop);
+
+ options (int start,
+ int& argc,
+ char** argv,
+ int& end,
+ bool erase = false,
+ ::cli::unknown_mode option = ::cli::unknown_mode::fail,
+ ::cli::unknown_mode argument = ::cli::unknown_mode::stop);
+
+ options (::cli::scanner&,
+ ::cli::unknown_mode option = ::cli::unknown_mode::fail,
+ ::cli::unknown_mode argument = ::cli::unknown_mode::stop);
+
+ options ();
+
+ // Option accessors.
+ //
+ const NarrowStrings&
+ type_map () const;
+
+ bool
+ type_map_specified () const;
+
+ const NarrowString&
+ xml_parser () const;
+
+ bool
+ xml_parser_specified () const;
+
+ const bool&
+ generate_validation () const;
+
+ const bool&
+ suppress_validation () const;
+
+ const bool&
+ generate_polymorphic () const;
+
+ const bool&
+ generate_noop_impl () const;
+
+ const bool&
+ generate_print_impl () const;
+
+ const bool&
+ generate_test_driver () const;
+
+ const bool&
+ force_overwrite () const;
+
+ const bool&
+ root_element_first () const;
+
+ const bool&
+ root_element_last () const;
+
+ const NarrowString&
+ root_element () const;
+
+ bool
+ root_element_specified () const;
+
+ const NarrowString&
+ skel_type_suffix () const;
+
+ bool
+ skel_type_suffix_specified () const;
+
+ const NarrowString&
+ skel_file_suffix () const;
+
+ bool
+ skel_file_suffix_specified () const;
+
+ const NarrowString&
+ impl_type_suffix () const;
+
+ bool
+ impl_type_suffix_specified () const;
+
+ const NarrowString&
+ impl_file_suffix () const;
+
+ bool
+ impl_file_suffix_specified () const;
+
+ // Print usage information.
+ //
+ static void
+ print_usage (::std::wostream&);
+
+ // Implementation details.
+ //
+ protected:
+ bool
+ _parse (const char*, ::cli::scanner&);
+
+ private:
+ void
+ _parse (::cli::scanner&,
+ ::cli::unknown_mode option,
+ ::cli::unknown_mode argument);
+
+ public:
+ NarrowStrings type_map_;
+ bool type_map_specified_;
+ NarrowString xml_parser_;
+ bool xml_parser_specified_;
+ bool generate_validation_;
+ bool suppress_validation_;
+ bool generate_polymorphic_;
+ bool generate_noop_impl_;
+ bool generate_print_impl_;
+ bool generate_test_driver_;
+ bool force_overwrite_;
+ bool root_element_first_;
+ bool root_element_last_;
+ NarrowString root_element_;
+ bool root_element_specified_;
+ NarrowString skel_type_suffix_;
+ bool skel_type_suffix_specified_;
+ NarrowString skel_file_suffix_;
+ bool skel_file_suffix_specified_;
+ NarrowString impl_type_suffix_;
+ bool impl_type_suffix_specified_;
+ NarrowString impl_file_suffix_;
+ bool impl_file_suffix_specified_;
+ };
+ }
+}
+
+#include <cxx/parser/options.ixx>
+
+// Begin epilogue.
+//
+//
+// End epilogue.
+
+#endif // CXX_PARSER_OPTIONS_HXX
diff --git a/xsd/xsd/cxx/parser/options.ixx b/xsd/xsd/cxx/parser/options.ixx
new file mode 100644
index 0000000..22ab11d
--- /dev/null
+++ b/xsd/xsd/cxx/parser/options.ixx
@@ -0,0 +1,160 @@
+// This code was generated by CLI, a command line interface
+// compiler for C++.
+//
+
+// Begin prologue.
+//
+//
+// End prologue.
+
+namespace CXX
+{
+ namespace Parser
+ {
+ // options
+ //
+
+ inline const NarrowStrings& options::
+ type_map () const
+ {
+ return this->type_map_;
+ }
+
+ inline bool options::
+ type_map_specified () const
+ {
+ return this->type_map_specified_;
+ }
+
+ inline const NarrowString& options::
+ xml_parser () const
+ {
+ return this->xml_parser_;
+ }
+
+ inline bool options::
+ xml_parser_specified () const
+ {
+ return this->xml_parser_specified_;
+ }
+
+ inline const bool& options::
+ generate_validation () const
+ {
+ return this->generate_validation_;
+ }
+
+ inline const bool& options::
+ suppress_validation () const
+ {
+ return this->suppress_validation_;
+ }
+
+ inline const bool& options::
+ generate_polymorphic () const
+ {
+ return this->generate_polymorphic_;
+ }
+
+ inline const bool& options::
+ generate_noop_impl () const
+ {
+ return this->generate_noop_impl_;
+ }
+
+ inline const bool& options::
+ generate_print_impl () const
+ {
+ return this->generate_print_impl_;
+ }
+
+ inline const bool& options::
+ generate_test_driver () const
+ {
+ return this->generate_test_driver_;
+ }
+
+ inline const bool& options::
+ force_overwrite () const
+ {
+ return this->force_overwrite_;
+ }
+
+ inline const bool& options::
+ root_element_first () const
+ {
+ return this->root_element_first_;
+ }
+
+ inline const bool& options::
+ root_element_last () const
+ {
+ return this->root_element_last_;
+ }
+
+ inline const NarrowString& options::
+ root_element () const
+ {
+ return this->root_element_;
+ }
+
+ inline bool options::
+ root_element_specified () const
+ {
+ return this->root_element_specified_;
+ }
+
+ inline const NarrowString& options::
+ skel_type_suffix () const
+ {
+ return this->skel_type_suffix_;
+ }
+
+ inline bool options::
+ skel_type_suffix_specified () const
+ {
+ return this->skel_type_suffix_specified_;
+ }
+
+ inline const NarrowString& options::
+ skel_file_suffix () const
+ {
+ return this->skel_file_suffix_;
+ }
+
+ inline bool options::
+ skel_file_suffix_specified () const
+ {
+ return this->skel_file_suffix_specified_;
+ }
+
+ inline const NarrowString& options::
+ impl_type_suffix () const
+ {
+ return this->impl_type_suffix_;
+ }
+
+ inline bool options::
+ impl_type_suffix_specified () const
+ {
+ return this->impl_type_suffix_specified_;
+ }
+
+ inline const NarrowString& options::
+ impl_file_suffix () const
+ {
+ return this->impl_file_suffix_;
+ }
+
+ inline bool options::
+ impl_file_suffix_specified () const
+ {
+ return this->impl_file_suffix_specified_;
+ }
+ }
+}
+
+// Begin epilogue.
+//
+//
+// End epilogue.
diff --git a/xsd/xsd/cxx/parser/parser-forward.cxx b/xsd/xsd/cxx/parser/parser-forward.cxx
index a4e8ae7..faf427a 100644
--- a/xsd/xsd/cxx/parser/parser-forward.cxx
+++ b/xsd/xsd/cxx/parser/parser-forward.cxx
@@ -1,6 +1,5 @@
// file : xsd/cxx/parser/parser-forward.cxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#include <cxx/parser/parser-forward.hxx>
@@ -21,7 +20,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& e)
{
os << "class " << ename (e) << ";";
@@ -37,7 +36,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& l)
{
os << "class " << ename (l) << ";";
@@ -53,7 +52,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& u)
{
os << "class " << ename (u) << ";";
@@ -69,7 +68,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& c)
{
os << "class " << ename (c) << ";";
@@ -77,7 +76,7 @@ namespace CXX
};
}
- Void
+ void
generate_parser_forward (Context& ctx)
{
ctx.os << "// Forward declarations" << endl
@@ -85,7 +84,7 @@ namespace CXX
Traversal::Schema schema;
- Traversal::Sources sources;
+ Sources sources;
Traversal::Names schema_names;
Namespace ns (ctx);
diff --git a/xsd/xsd/cxx/parser/parser-forward.hxx b/xsd/xsd/cxx/parser/parser-forward.hxx
index a8a17f1..53c7049 100644
--- a/xsd/xsd/cxx/parser/parser-forward.hxx
+++ b/xsd/xsd/cxx/parser/parser-forward.hxx
@@ -1,6 +1,5 @@
// file : xsd/cxx/parser/parser-forward.hxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#ifndef CXX_PARSER_PARSER_FORWARD_HXX
@@ -12,7 +11,7 @@ namespace CXX
{
namespace Parser
{
- Void
+ void
generate_parser_forward (Context&);
}
}
diff --git a/xsd/xsd/cxx/parser/parser-header.cxx b/xsd/xsd/cxx/parser/parser-header.cxx
index aade743..800a4b9 100644
--- a/xsd/xsd/cxx/parser/parser-header.cxx
+++ b/xsd/xsd/cxx/parser/parser-header.cxx
@@ -1,13 +1,16 @@
// file : xsd/cxx/parser/parser-header.cxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+#include <set>
+
#include <cxx/parser/parser-header.hxx>
#include <xsd-frontend/semantic-graph.hxx>
#include <xsd-frontend/traversal.hxx>
+using namespace std;
+
namespace CXX
{
namespace Parser
@@ -21,7 +24,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& e)
{
String const& name (ename (e));
@@ -41,7 +44,7 @@ namespace CXX
String const& ret (ret_type (e));
- Boolean same (ret == ret_type (base));
+ bool same (ret == ret_type (base));
os << "virtual " << ret << endl
<< post_name (e) << " ()" <<
@@ -71,7 +74,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& l)
{
String const& name (ename (l));
@@ -173,7 +176,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& u)
{
String const& name (ename (u));
@@ -222,7 +225,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& m)
{
if (skip (m)) return;
@@ -251,7 +254,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& m)
{
if (skip (m))
@@ -281,7 +284,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& m)
{
if (skip (m))
@@ -295,8 +298,7 @@ namespace CXX
m.is_a<SemanticGraph::Element> () &&
!anonymous (m.type ()))
{
- os << type << "* " << emember_cache (m) << ";"
- << "const " << parser_map << "* " << emember_map (m) << ";"
+ os << "const " << parser_map << "* " << emember_map (m) << ";"
<< endl;
}
}
@@ -316,14 +318,13 @@ namespace CXX
}
- virtual Void
+ virtual void
traverse (SemanticGraph::All& a)
{
if (!a.context().count ("comp-number"))
return;
- UnsignedLong state_count (
- a.context().get<UnsignedLong> ("state-count"));
+ size_t state_count (a.context().get<size_t> ("state-count"));
os << "void" << endl
<< "all_0 (unsigned long& state," << endl
@@ -338,13 +339,13 @@ namespace CXX
<< endl;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Choice& c)
{
if (!c.context().count ("comp-number"))
return;
- UnsignedLong n (c.context ().get<UnsignedLong> ("comp-number"));
+ size_t n (c.context ().get<size_t> ("comp-number"));
os << "void" << endl
<< "choice_" << n << " (unsigned long& state," << endl
@@ -358,13 +359,13 @@ namespace CXX
Traversal::Choice::traverse (c);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Sequence& s)
{
if (!s.context().count ("comp-number"))
return;
- UnsignedLong n (s.context ().get<UnsignedLong> ("comp-number"));
+ size_t n (s.context ().get<size_t> ("comp-number"));
os << "void" << endl
<< "sequence_" << n << " (unsigned long& state," << endl
@@ -392,7 +393,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& a)
{
if (!a.optional_p ())
@@ -419,7 +420,7 @@ namespace CXX
names_attribute_validation_state_ >> attribute_validation_state_;
}
- virtual Void
+ virtual void
traverse (Type& c)
{
String const& name (ename (c));
@@ -428,15 +429,15 @@ namespace CXX
// generate parser callbacks, etc. since they are the same as in
// the base. We only need the parsing/validation code.
//
- Boolean restriction (restriction_p (c));
+ bool restriction (restriction_p (c));
- Boolean he (has<Traversal::Element> (c));
- Boolean ha (has<Traversal::Attribute> (c));
+ bool he (has<Traversal::Element> (c));
+ bool ha (has<Traversal::Attribute> (c));
- Boolean hae (has_particle<Traversal::Any> (c));
- Boolean haa (has<Traversal::AnyAttribute> (c));
+ bool hae (has_particle<Traversal::Any> (c));
+ bool haa (has<Traversal::AnyAttribute> (c));
- Boolean hra (false); // Has required attribute.
+ bool hra (false); // Has required attribute.
if (ha)
{
RequiredAttributeTest test (hra);
@@ -472,7 +473,7 @@ namespace CXX
String const& ret (ret_type (c));
- Boolean same (c.inherits_p () &&
+ bool same (c.inherits_p () &&
ret == ret_type (c.inherits ().base ()));
os << "virtual " << ret << endl
@@ -606,7 +607,7 @@ namespace CXX
if (validation && (he || hae))
{
- UnsignedLong depth (c.context ().get<UnsignedLong> ("depth"));
+ size_t depth (c.context ().get<size_t> ("depth"));
os << "protected:" << endl;
@@ -770,13 +771,13 @@ namespace CXX
// anyType & anySimpleType.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::AnyType& t)
{
gen_typedef (t, "void", "any_type_pskel", "any_type_pimpl");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::AnySimpleType& t)
{
gen_typedef (t, "void",
@@ -785,7 +786,7 @@ namespace CXX
// Boolean.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Boolean& t)
{
gen_typedef (t, "bool", "boolean_pskel", "boolean_pimpl");
@@ -793,72 +794,72 @@ namespace CXX
// Integral types.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Byte& t)
{
gen_typedef (t, "signed char", "byte_pskel", "byte_pimpl");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::UnsignedByte& t)
{
gen_typedef (t, "unsigned char",
"unsigned_byte_pskel", "unsigned_byte_pimpl");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Short& t)
{
gen_typedef (t, "short", "short_pskel", "short_pimpl");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::UnsignedShort& t)
{
gen_typedef (t, "unsigned short",
"unsigned_short_pskel", "unsigned_short_pimpl");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Int& t)
{
gen_typedef (t, "int", "int_pskel", "int_pimpl");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::UnsignedInt& t)
{
gen_typedef (t, "unsigned int",
"unsigned_int_pskel", "unsigned_int_pimpl");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Long& t)
{
gen_typedef (t, "long long", "long_pskel", "long_pimpl");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::UnsignedLong& t)
{
gen_typedef (t, "unsigned long long",
"unsigned_long_pskel", "unsigned_long_pimpl");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Integer& t)
{
gen_typedef (t, "long long", "integer_pskel", "integer_pimpl");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NegativeInteger& t)
{
gen_typedef (t, "long long",
"negative_integer_pskel", "negative_integer_pimpl");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NonPositiveInteger& t)
{
gen_typedef (t, "long long",
@@ -866,14 +867,14 @@ namespace CXX
"non_positive_integer_pimpl");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::PositiveInteger& t)
{
gen_typedef (t, "unsigned long long",
"positive_integer_pskel", "positive_integer_pimpl");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NonNegativeInteger& t)
{
gen_typedef (t, "unsigned long long",
@@ -883,19 +884,19 @@ namespace CXX
// Floats.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Float& t)
{
gen_typedef (t, "float", "float_pskel", "float_pimpl");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Double& t)
{
gen_typedef (t, "double", "double_pskel", "double_pimpl");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Decimal& t)
{
gen_typedef (t, "double", "decimal_pskel", "decimal_pimpl");
@@ -903,33 +904,33 @@ namespace CXX
// Strings.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::String& t)
{
gen_typedef (t, string_type_, "string_pskel", "string_pimpl");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NormalizedString& t)
{
gen_typedef (t, string_type_,
"normalized_string_pskel", "normalized_string_pimpl");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Token& t)
{
gen_typedef (t, string_type_, "token_pskel", "token_pimpl");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NameToken& t)
{
nmtoken_ = gen_typedef (t, string_type_,
"nmtoken_pskel", "nmtoken_pimpl");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NameTokens& t)
{
// NMTOKENS uses NMTOKEN implementation to parse individual items.
@@ -941,19 +942,19 @@ namespace CXX
"nmtokens_pskel", "nmtokens_pimpl");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Name& t)
{
gen_typedef (t, string_type_, "name_pskel", "name_pimpl");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NCName& t)
{
gen_typedef (t, string_type_, "ncname_pskel", "ncname_pimpl");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Language& t)
{
gen_typedef (t, string_type_, "language_pskel", "language_pimpl");
@@ -961,7 +962,7 @@ namespace CXX
// Qualified name.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::QName& t)
{
gen_typedef (t, xs_ns_ + L"::qname", "qname_pskel", "qname_pimpl");
@@ -969,19 +970,19 @@ namespace CXX
// ID/IDREF.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Id& t)
{
gen_typedef (t, string_type_, "id_pskel", "id_pimpl");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::IdRef& t)
{
idref_ = gen_typedef (t, string_type_, "idref_pskel", "idref_pimpl");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::IdRefs& t)
{
// IDREFS uses IDREF implementation to parse individual items.
@@ -995,7 +996,7 @@ namespace CXX
// URI.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::AnyURI& t)
{
gen_typedef (t, string_type_, "uri_pskel", "uri_pimpl");
@@ -1003,78 +1004,78 @@ namespace CXX
// Binary.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Base64Binary& t)
{
- String buffer (L"::std::auto_ptr< " + xs_ns_ + L"::buffer >");
+ String buffer (auto_ptr + L"< " + xs_ns_ + L"::buffer >");
gen_typedef (t, buffer,
"base64_binary_pskel", "base64_binary_pimpl");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::HexBinary& t)
{
- String buffer (L"::std::auto_ptr< " + xs_ns_ + L"::buffer >");
+ String buffer (auto_ptr + L"< " + xs_ns_ + L"::buffer >");
gen_typedef (t, buffer, "hex_binary_pskel", "hex_binary_pimpl");
}
// Date/time.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Date& t)
{
gen_typedef (t, xs_ns_ + L"::date", "date_pskel", "date_pimpl");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::DateTime& t)
{
gen_typedef (t, xs_ns_ + L"::date_time",
"date_time_pskel", "date_time_pimpl");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Duration& t)
{
gen_typedef (t, xs_ns_ + L"::duration",
"duration_pskel", "duration_pimpl");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Day& t)
{
gen_typedef (t, xs_ns_ + L"::gday", "gday_pskel", "gday_pimpl");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Month& t)
{
gen_typedef (t, xs_ns_ + L"::gmonth",
"gmonth_pskel", "gmonth_pimpl");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::MonthDay& t)
{
gen_typedef (t, xs_ns_ + L"::gmonth_day",
"gmonth_day_pskel", "gmonth_day_pimpl");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Year& t)
{
gen_typedef (t, xs_ns_ + L"::gyear", "gyear_pskel", "gyear_pimpl");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::YearMonth& t)
{
gen_typedef (t, xs_ns_ + L"::gyear_month",
"gyear_month_pskel", "gyear_month_pimpl");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Time& t)
{
gen_typedef (t, xs_ns_ + L"::time", "time_pskel", "time_pimpl");
@@ -1082,18 +1083,18 @@ namespace CXX
// Entity.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Entity&)
{
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Entities&)
{
}
private:
- Boolean
+ bool
gen_typedef (SemanticGraph::Type& t,
String const& type,
String const& pskel,
@@ -1120,8 +1121,8 @@ namespace CXX
String impl_ns_;
String string_type_;
- Boolean idref_;
- Boolean nmtoken_;
+ bool idref_;
+ bool nmtoken_;
};
struct FundNamespace: Namespace, Context
@@ -1258,8 +1259,8 @@ namespace CXX
};
}
- Void
- generate_parser_header (Context& ctx, Boolean generate_xml_schema)
+ void
+ generate_parser_header (Context& ctx, bool generate_xml_schema)
{
String c (ctx.char_type);
@@ -1295,11 +1296,11 @@ namespace CXX
NarrowString extern_xml_schema;
if (!generate_xml_schema)
- extern_xml_schema = ctx.options.value<CLI::extern_xml_schema> ();
+ extern_xml_schema = ctx.options.extern_xml_schema ();
if (extern_xml_schema)
{
- String name (ctx.hxx_expr->merge (extern_xml_schema));
+ String name (ctx.hxx_expr->replace (extern_xml_schema));
ctx.os << "#include " << ctx.process_include_path (name) << endl
<< endl;
@@ -1308,12 +1309,12 @@ namespace CXX
//
if (ctx.schema_root.context ().count ("includes"))
{
- typedef Cult::Containers::Set<String> Includes;
+ typedef set<String> Includes;
Includes const& is (
ctx.schema_root.context ().get<Includes> ("includes"));
- for (Includes::ConstReverseIterator i (is.rbegin ());
+ for (Includes::const_reverse_iterator i (is.rbegin ());
i != is.rend (); ++i)
{
ctx.os << "#include " << *i << endl;
@@ -1357,12 +1358,12 @@ namespace CXX
//
if (ctx.schema_root.context ().count ("includes"))
{
- typedef Cult::Containers::Set<String> Includes;
+ typedef set<String> Includes;
Includes const& is (
ctx.schema_root.context ().get<Includes> ("includes"));
- for (Includes::ConstReverseIterator i (is.rbegin ());
+ for (Includes::const_reverse_iterator i (is.rbegin ());
i != is.rend (); ++i)
{
ctx.os << "#include " << *i << endl;
@@ -1412,7 +1413,7 @@ namespace CXX
{
Traversal::Schema schema;
- Traversal::Sources sources;
+ Sources sources;
Includes includes (ctx, Includes::header);
Traversal::Names schema_names;
diff --git a/xsd/xsd/cxx/parser/parser-header.hxx b/xsd/xsd/cxx/parser/parser-header.hxx
index c4e114d..467dcb5 100644
--- a/xsd/xsd/cxx/parser/parser-header.hxx
+++ b/xsd/xsd/cxx/parser/parser-header.hxx
@@ -1,6 +1,5 @@
// file : xsd/cxx/parser/parser-header.hxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#ifndef CXX_PARSER_PARSER_HEADER_HXX
@@ -12,8 +11,8 @@ namespace CXX
{
namespace Parser
{
- Void
- generate_parser_header (Context&, Boolean generate_xml_schema);
+ void
+ generate_parser_header (Context&, bool generate_xml_schema);
}
}
diff --git a/xsd/xsd/cxx/parser/parser-inline.cxx b/xsd/xsd/cxx/parser/parser-inline.cxx
index b491b72..87ba92c 100644
--- a/xsd/xsd/cxx/parser/parser-inline.cxx
+++ b/xsd/xsd/cxx/parser/parser-inline.cxx
@@ -1,6 +1,5 @@
// file : xsd/cxx/parser/parser-inline.cxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#include <cxx/parser/parser-inline.hxx>
@@ -23,7 +22,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& l)
{
String const& name (ename (l));
@@ -75,7 +74,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& m)
{
if (skip (m))
@@ -84,7 +83,7 @@ namespace CXX
String const& scope (ename (m.scope ()));
String const& parser (eparser (m));
- Boolean poly (polymorphic &&
+ bool poly (polymorphic &&
m.is_a<SemanticGraph::Element> () &&
!anonymous (m.type ()));
@@ -117,7 +116,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& m)
{
if (skip (m)) return;
@@ -138,7 +137,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& m)
{
if (skip (m)) return;
@@ -159,14 +158,14 @@ namespace CXX
}
}
- Boolean
+ bool
comma () const
{
return !first_;
}
private:
- Boolean first_;
+ bool first_;
};
struct ParserBaseSet: Traversal::Complex,
@@ -180,7 +179,7 @@ namespace CXX
names_ >> member_;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Complex& c)
{
inherits (c, inherits_);
@@ -189,7 +188,7 @@ namespace CXX
names (c, names_);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::List& l)
{
String const& name (ename (l));
@@ -212,14 +211,13 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (SemanticGraph::All& a)
{
if (!a.context().count ("comp-number"))
return;
- UnsignedLong state_count (
- a.context().get<UnsignedLong> ("state-count"));
+ size_t state_count (a.context().get<size_t> ("state-count"));
os << "," << endl
<< " v_all_count_ (" << state_count << "UL, v_all_first_)";
@@ -242,15 +240,15 @@ namespace CXX
names_parser_member_set_ >> parser_member_set_;
}
- virtual Void
+ virtual void
traverse (Type& c)
{
- Boolean he (has<Traversal::Element> (c));
- Boolean ha (has<Traversal::Attribute> (c));
+ bool he (has<Traversal::Element> (c));
+ bool ha (has<Traversal::Attribute> (c));
- Boolean hae (has_particle<Traversal::Any> (c));
+ bool hae (has_particle<Traversal::Any> (c));
- Boolean hra (false); // Has required attribute.
+ bool hra (false); // Has required attribute.
if (ha)
{
RequiredAttributeTest test (hra);
@@ -258,7 +256,7 @@ namespace CXX
names (c, names_test);
}
- Boolean restriction (restriction_p (c));
+ bool restriction (restriction_p (c));
if (!((!restriction && (he || ha)) ||
(validation && (he || hae || hra))))
@@ -305,7 +303,7 @@ namespace CXX
<< name << " ()" << endl
<< ": ";
- Boolean comma (false);
+ bool comma (false);
if (!restriction && (he || ha))
{
@@ -364,13 +362,13 @@ namespace CXX
};
}
- Void
+ void
generate_parser_inline (Context& ctx)
{
// Emit "weak" header includes that are used in the file-per-type
// compilation model.
//
- if (!ctx.options.value<CLI::generate_inline> ())
+ if (!ctx.options.generate_inline ())
{
Traversal::Schema schema;
Includes includes (ctx, Includes::source);
@@ -381,7 +379,7 @@ namespace CXX
Traversal::Schema schema;
- Traversal::Sources sources;
+ Sources sources;
Traversal::Names schema_names;
Namespace ns (ctx);
diff --git a/xsd/xsd/cxx/parser/parser-inline.hxx b/xsd/xsd/cxx/parser/parser-inline.hxx
index 51f5b93..aff2ad2 100644
--- a/xsd/xsd/cxx/parser/parser-inline.hxx
+++ b/xsd/xsd/cxx/parser/parser-inline.hxx
@@ -1,6 +1,5 @@
// file : xsd/cxx/parser/parser-inline.hxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#ifndef CXX_PARSER_PARSER_INLINE_HXX
@@ -12,7 +11,7 @@ namespace CXX
{
namespace Parser
{
- Void
+ void
generate_parser_inline (Context&);
}
}
diff --git a/xsd/xsd/cxx/parser/parser-source.cxx b/xsd/xsd/cxx/parser/parser-source.cxx
index 99bc566..2ee5273 100644
--- a/xsd/xsd/cxx/parser/parser-source.cxx
+++ b/xsd/xsd/cxx/parser/parser-source.cxx
@@ -1,6 +1,5 @@
// file : xsd/cxx/parser/parser-source.cxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#include <cxx/parser/parser-source.hxx>
@@ -21,7 +20,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& e)
{
String const& name (ename (e));
@@ -29,7 +28,7 @@ namespace CXX
SemanticGraph::Type& base (e.inherits ().base ());
- Boolean same (ret == ret_type (base));
+ bool same (ret == ret_type (base));
if (same || ret == L"void" || polymorphic)
{
@@ -79,7 +78,7 @@ namespace CXX
if (validation)
{
- Boolean gen (!anonymous (e));
+ bool gen (!anonymous (e));
// We normally don't need to enter anonymous types into
// the inheritance map. The only exception is when an
@@ -89,16 +88,21 @@ namespace CXX
if (!gen)
{
// The first instance that this anonymous type classifies
- // is the prototype for others if any.
+ // is the prototype for others if any. If this type does
+ // not classify anything (e.g., it is a base), then we
+ // don't need to do anything.
//
- SemanticGraph::Instance& i (
- e.classifies_begin ()->instance ());
-
- if (SemanticGraph::Element* e =
- dynamic_cast<SemanticGraph::Element*> (&i))
+ if (e.classifies_begin () != e.classifies_end ())
{
- if (e->substitutes_p ())
- gen = true;
+ SemanticGraph::Instance& i (
+ e.classifies_begin ()->instance ());
+
+ if (SemanticGraph::Element* e =
+ dynamic_cast<SemanticGraph::Element*> (&i))
+ {
+ if (e->substitutes_p ())
+ gen = true;
+ }
}
}
@@ -126,7 +130,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& l)
{
String const& name (ename (l));
@@ -222,7 +226,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& u)
{
String const& name (ename (u));
@@ -277,15 +281,13 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& e)
{
if (skip (e))
return;
- Boolean poly (polymorphic && !anonymous (e.type ()));
-
- String const& inst (poly ? emember_cache (e) : emember (e));
+ bool poly (polymorphic && !anonymous (e.type ()));
os << "if (";
@@ -316,9 +318,12 @@ namespace CXX
os << ")"
<< "{";
+ String inst;
+
if (poly)
{
SemanticGraph::Type& t (e.type ());
+ inst = "p";
// For pre-computing length.
//
@@ -334,8 +339,10 @@ namespace CXX
String const& member (emember (e));
String const& member_map (emember_map (e));
- os << "if (t == 0 && this->" << member << " != 0)" << endl
- << "this->" << inst << " = this->" << member << ";"
+ os << fq_type << "* p = 0;"
+ << endl
+ << "if (t == 0 && this->" << member << " != 0)" << endl
+ << inst << " = this->" << member << ";"
<< "else"
<< "{"
<< string_type << " ts (" << fq_type <<
@@ -345,21 +352,21 @@ namespace CXX
<< "t = &ts;"
<< endl
<< "if (this->" << member << " != 0 && *t == ts)" << endl
- << "this->" << inst << " = this->" << member << ";"
+ << inst << " = this->" << member << ";"
<< "else if (this->" << member_map << " != 0)" << endl
- << "this->" << inst << " = dynamic_cast< " << fq_type <<
+ << inst << " = dynamic_cast< " << fq_type <<
"* > (" << endl
<< "this->" << member_map << "->find (*t));"
- << "else" << endl
- << "this->" << inst << " = 0;"
<< "}";
}
+ else
+ inst = L"this->" + emember (e);
os << "this->" << complex_base << "::context_.top ().parser_ = " <<
- "this->" << inst << ";"
+ inst << ";"
<< endl
- << "if (this->" << inst << ")" << endl
- << "this->" << inst << "->pre ();" // _start_element calls _pre
+ << "if (" << inst << ")" << endl
+ << inst << "->pre ();" // _start_element calls _pre
<< endl
<< "return true;"
<< "}";
@@ -376,16 +383,14 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& e)
{
if (skip (e))
return;
- Boolean poly (polymorphic && !anonymous (e.type ()));
-
+ bool poly (polymorphic && !anonymous (e.type ()));
String const& name (ename (e));
- String const& inst (poly ? emember_cache (e) : emember (e));
os << "if (";
@@ -421,18 +426,31 @@ namespace CXX
SemanticGraph::Type& type (e.type ());
String const& post (post_name (type));
+ String inst;
+
+ if (poly)
+ {
+ String const& fq_type (fq_name (type));
+ inst = "p";
- os << "if (this->" << inst << ")";
+ os << fq_type << "* p =" << endl
+ << "dynamic_cast< " << fq_type << "* > (" << endl
+ << "this->" << complex_base << "::context_.top ().parser_);"
+ << endl;
+ }
+ else
+ inst = L"this->" + emember (e);
+
+ os << "if (" << inst << ")";
if (ret_type (type) == L"void")
os << "{"
- << "this->" << inst << "->" << post << " ();"
+ << inst << "->" << post << " ();"
<< "this->" << name << " ();"
<< "}";
else
os << endl
- << "this->" << name << " (this->" << inst << "->" <<
- post << " ());"
+ << "this->" << name << " (" << inst << "->" << post << " ());"
<< endl;
os << "return true;"
@@ -449,7 +467,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& a)
{
String const& name (ename (a));
@@ -500,7 +518,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& m)
{
if (skip (m))
@@ -538,14 +556,14 @@ namespace CXX
names_attribute_ >> attribute_;
}
- virtual Void
+ virtual void
traverse (Type& c)
{
- Boolean he (has<Traversal::Element> (c));
- Boolean ha (has<Traversal::Attribute> (c));
+ bool he (has<Traversal::Element> (c));
+ bool ha (has<Traversal::Attribute> (c));
String const& ret (ret_type (c));
- Boolean same (c.inherits_p () &&
+ bool same (c.inherits_p () &&
ret == ret_type (c.inherits ().base ()));
String const& name (ename (c));
@@ -581,7 +599,7 @@ namespace CXX
if (c.inherits_p () && validation)
{
- Boolean gen (!anonymous (c));
+ bool gen (!anonymous (c));
// We normally don't need to enter anonymous types into
// the inheritance map. The only exception is when an
@@ -591,16 +609,21 @@ namespace CXX
if (!gen)
{
// The first instance that this anonymous type classifies
- // is the prototype for others if any.
+ // is the prototype for others if any. If this type does
+ // not classify anything (e.g., it is a base), then we
+ // don't need to do anything.
//
- SemanticGraph::Instance& i (
- c.classifies_begin ()->instance ());
-
- if (SemanticGraph::Element* e =
- dynamic_cast<SemanticGraph::Element*> (&i))
+ if (c.classifies_begin () != c.classifies_end ())
{
- if (e->substitutes_p ())
- gen = true;
+ SemanticGraph::Instance& i (
+ c.classifies_begin ()->instance ());
+
+ if (SemanticGraph::Element* e =
+ dynamic_cast<SemanticGraph::Element*> (&i))
+ {
+ if (e->substitutes_p ())
+ gen = true;
+ }
}
}
@@ -655,7 +678,7 @@ namespace CXX
// Don't use restriction_p here since we don't want special
// treatment of anyType.
//
- Boolean restriction (
+ bool restriction (
c.inherits_p () &&
c.inherits ().is_a<SemanticGraph::Restricts> ());
@@ -782,7 +805,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& e)
{
if (e.substitutes_p ())
@@ -809,7 +832,7 @@ namespace CXX
};
}
- Void
+ void
generate_parser_source (Context& ctx)
{
if (ctx.polymorphic)
@@ -822,8 +845,8 @@ namespace CXX
else
ctx.os << endl;
- Boolean import_maps (ctx.options.value<CLI::import_maps> ());
- Boolean export_maps (ctx.options.value<CLI::export_maps> ());
+ bool import_maps (ctx.options.import_maps ());
+ bool export_maps (ctx.options.export_maps ());
if (import_maps || export_maps)
{
@@ -896,7 +919,7 @@ namespace CXX
// Emit "weak" header includes that are used in the file-per-type
// compilation model.
//
- if (ctx.options.value<CLI::generate_inline> ())
+ if (ctx.options.generate_inline ())
{
Traversal::Schema schema;
Includes includes (ctx, Includes::source);
@@ -906,7 +929,7 @@ namespace CXX
}
Traversal::Schema schema;
- Traversal::Sources sources;
+ Sources sources;
Traversal::Names schema_names;
Namespace ns (ctx);
diff --git a/xsd/xsd/cxx/parser/parser-source.hxx b/xsd/xsd/cxx/parser/parser-source.hxx
index f6496ea..6e206b4 100644
--- a/xsd/xsd/cxx/parser/parser-source.hxx
+++ b/xsd/xsd/cxx/parser/parser-source.hxx
@@ -1,6 +1,5 @@
// file : xsd/cxx/parser/parser-source.hxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#ifndef CXX_PARSER_PARSER_SOURCE_HXX
@@ -12,7 +11,7 @@ namespace CXX
{
namespace Parser
{
- Void
+ void
generate_parser_source (Context&);
}
}
diff --git a/xsd/xsd/cxx/parser/print-impl-common.hxx b/xsd/xsd/cxx/parser/print-impl-common.hxx
index 5a91931..516273a 100644
--- a/xsd/xsd/cxx/parser/print-impl-common.hxx
+++ b/xsd/xsd/cxx/parser/print-impl-common.hxx
@@ -1,6 +1,5 @@
// file : xsd/cxx/parser/print-impl-common.hxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#ifndef CXX_PARSER_PRINT_IMPL_COMMON_HXX
@@ -74,7 +73,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Type&)
{
gen_user_type ();
@@ -82,7 +81,7 @@ namespace CXX
// Boolean.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Boolean& t)
{
if (default_type (t, "bool"))
@@ -96,7 +95,7 @@ namespace CXX
// Integral types.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Byte& t)
{
if (default_type (t, "signed char"))
@@ -108,7 +107,7 @@ namespace CXX
gen_user_type ();
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::UnsignedByte& t)
{
if (default_type (t, "unsigned char"))
@@ -120,7 +119,7 @@ namespace CXX
gen_user_type ();
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Short& t)
{
if (default_type (t, "short"))
@@ -132,7 +131,7 @@ namespace CXX
gen_user_type ();
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::UnsignedShort& t)
{
if (default_type (t, "unsigned short"))
@@ -144,7 +143,7 @@ namespace CXX
gen_user_type ();
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Int& t)
{
if (default_type (t, "int"))
@@ -156,7 +155,7 @@ namespace CXX
gen_user_type ();
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::UnsignedInt& t)
{
if (default_type (t, "unsigned int"))
@@ -168,7 +167,7 @@ namespace CXX
gen_user_type ();
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Long& t)
{
if (default_type (t, "long long"))
@@ -180,7 +179,7 @@ namespace CXX
gen_user_type ();
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::UnsignedLong& t)
{
if (default_type (t, "unsigned long long"))
@@ -192,7 +191,7 @@ namespace CXX
gen_user_type ();
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Integer& t)
{
if (default_type (t, "long long"))
@@ -204,7 +203,7 @@ namespace CXX
gen_user_type ();
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NegativeInteger& t)
{
if (default_type (t, "long long"))
@@ -216,7 +215,7 @@ namespace CXX
gen_user_type ();
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NonPositiveInteger& t)
{
if (default_type (t, "long long"))
@@ -228,7 +227,7 @@ namespace CXX
gen_user_type ();
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::PositiveInteger& t)
{
if (default_type (t, "unsigned long long"))
@@ -240,7 +239,7 @@ namespace CXX
gen_user_type ();
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NonNegativeInteger& t)
{
if (default_type (t, "unsigned long long"))
@@ -254,7 +253,7 @@ namespace CXX
// Floats.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Float& t)
{
if (default_type (t, "float"))
@@ -266,7 +265,7 @@ namespace CXX
gen_user_type ();
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Double& t)
{
if (default_type (t, "double"))
@@ -278,7 +277,7 @@ namespace CXX
gen_user_type ();
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Decimal& t)
{
if (default_type (t, "double"))
@@ -292,61 +291,61 @@ namespace CXX
// Strings.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::String& t)
{
gen_string (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NormalizedString& t)
{
gen_string (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Token& t)
{
gen_string (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NameToken& t)
{
gen_string (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Name& t)
{
gen_string (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NCName& t)
{
gen_string (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Language& t)
{
gen_string (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Id& t)
{
gen_string (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::IdRef& t)
{
gen_string (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::AnyURI& t)
{
gen_string (t);
@@ -355,13 +354,13 @@ namespace CXX
// String sequences.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NameTokens& t)
{
gen_sequence (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::IdRefs& t)
{
gen_sequence (t);
@@ -370,7 +369,7 @@ namespace CXX
// QName
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::QName& t)
{
if (default_type (t, xs_ns_name () + L"::qname"))
@@ -391,13 +390,13 @@ namespace CXX
// Binary.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Base64Binary& t)
{
gen_buffer (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::HexBinary& t)
{
gen_buffer (t);
@@ -405,7 +404,7 @@ namespace CXX
// Date/time.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Date& t)
{
if (default_type (t, xs_ns_name () + L"::date"))
@@ -421,7 +420,7 @@ namespace CXX
gen_user_type ();
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::DateTime& t)
{
if (default_type (t, xs_ns_name () + L"::date_time"))
@@ -440,7 +439,7 @@ namespace CXX
gen_user_type ();
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Duration& t)
{
if (default_type (t, xs_ns_name () + L"::duration"))
@@ -463,7 +462,7 @@ namespace CXX
gen_user_type ();
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Day& t)
{
if (default_type (t, xs_ns_name () + L"::gday"))
@@ -477,7 +476,7 @@ namespace CXX
gen_user_type ();
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Month& t)
{
if (default_type (t, xs_ns_name () + L"::gmonth"))
@@ -491,7 +490,7 @@ namespace CXX
gen_user_type ();
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::MonthDay& t)
{
if (default_type (t, xs_ns_name () + L"::gmonth_day"))
@@ -506,7 +505,7 @@ namespace CXX
gen_user_type ();
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Year& t)
{
if (default_type (t, xs_ns_name () + L"::gyear"))
@@ -520,7 +519,7 @@ namespace CXX
gen_user_type ();
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::YearMonth& t)
{
if (default_type (t, xs_ns_name () + L"::gyear_month"))
@@ -535,7 +534,7 @@ namespace CXX
gen_user_type ();
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Time& t)
{
if (default_type (t, xs_ns_name () + L"::time"))
@@ -605,7 +604,7 @@ namespace CXX
void
gen_buffer (SemanticGraph::Type& t)
{
- String type (L"::std::auto_ptr< " + xs_ns_name () + L"::buffer >");
+ String type (auto_ptr + L"< " + xs_ns_name () + L"::buffer >");
if (default_type (t, type))
{
diff --git a/xsd/xsd/cxx/parser/state-processor.cxx b/xsd/xsd/cxx/parser/state-processor.cxx
index 7fe3ff6..86f97ce 100644
--- a/xsd/xsd/cxx/parser/state-processor.cxx
+++ b/xsd/xsd/cxx/parser/state-processor.cxx
@@ -1,8 +1,10 @@
// file : xsd/cxx/parser/state-processor.cxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2006-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2006-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+#include <vector>
+#include <iostream>
+
#include <cxx/parser/state-processor.hxx>
#include <cxx/parser/elements.hxx>
@@ -10,9 +12,7 @@
#include <xsd-frontend/semantic-graph.hxx>
#include <xsd-frontend/traversal.hxx>
-#include <cult/containers/vector.hxx>
-
-#include <iostream>
+using namespace std;
namespace CXX
{
@@ -20,8 +20,9 @@ namespace CXX
{
namespace
{
- typedef Cult::Containers::Vector<SemanticGraph::Particle*> Particles;
+ typedef vector<SemanticGraph::Particle*> Particles;
+ /*
void
print (Particles const& p)
{
@@ -30,7 +31,7 @@ namespace CXX
wcerr << "prefixes: " << endl;
- for (Particles::ConstIterator i (p.begin ()); i != p.end (); ++i)
+ for (Particles::const_iterator i (p.begin ()); i != p.end (); ++i)
{
if (SemanticGraph::Element* e =
dynamic_cast<SemanticGraph::Element*> (*i))
@@ -45,6 +46,7 @@ namespace CXX
wcerr << endl;
}
+ */
//
//
@@ -52,10 +54,10 @@ namespace CXX
Traversal::Choice,
Traversal::Sequence
{
- Particle (UnsignedLong& all,
- UnsignedLong& choice,
- UnsignedLong& sequence,
- UnsignedLong& depth)
+ Particle (size_t& all,
+ size_t& choice,
+ size_t& sequence,
+ size_t& depth)
: all_ (all),
choice_ (choice),
sequence_ (sequence),
@@ -63,7 +65,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (SemanticGraph::All& a)
{
using SemanticGraph::Compositor;
@@ -78,8 +80,8 @@ namespace CXX
// compositor cannot contain any nested compositors.
//
- UnsignedLong state (0);
- UnsignedLong min (0);
+ size_t state (0);
+ size_t min (0);
for (Compositor::ContainsIterator ci (a.contains_begin ());
ci != a.contains_end (); ++ci)
@@ -101,7 +103,7 @@ namespace CXX
{
a.context ().set ("comp-number", choice_++);
a.context ().set ("prefixes", prefixes_);
- a.context ().set ("state-count", UnsignedLong (prefixes_.size ()));
+ a.context ().set ("state-count", size_t (prefixes_.size ()));
// effective-min = min * actual-min
//
@@ -114,7 +116,7 @@ namespace CXX
}
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Choice& c)
{
using SemanticGraph::Compositor;
@@ -126,8 +128,8 @@ namespace CXX
// the actual value specified in the schema.
//
- UnsignedLong state (0);
- UnsignedLong min (1);
+ size_t state (0);
+ size_t min (1);
for (Compositor::ContainsIterator ci (c.contains_begin ());
ci != c.contains_end (); ++ci)
@@ -144,7 +146,7 @@ namespace CXX
}
else
{
- UnsignedLong depth (0);
+ size_t depth (0);
Particle t (all_, choice_, sequence_, depth);
t.dispatch (p);
@@ -159,7 +161,7 @@ namespace CXX
t.prefixes_.end ().base ());
if (min == 1 &&
- p.context ().get<UnsignedLong> ("effective-min") == 0)
+ p.context ().get<size_t> ("effective-min") == 0)
min = 0;
}
@@ -183,7 +185,7 @@ namespace CXX
}
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Sequence& s)
{
using SemanticGraph::Compositor;
@@ -195,9 +197,9 @@ namespace CXX
// of the actual value specified in the schema.
//
- Boolean prefix (true);
- UnsignedLong state (0);
- UnsignedLong min (0);
+ bool prefix (true);
+ size_t state (0);
+ size_t min (0);
for (Compositor::ContainsIterator ci (s.contains_begin ());
ci != s.contains_end (); ++ci)
@@ -217,7 +219,7 @@ namespace CXX
}
else
{
- UnsignedLong depth (0);
+ size_t depth (0);
Particle t (all_, choice_, sequence_, depth);
t.dispatch (p);
@@ -233,7 +235,7 @@ namespace CXX
t.prefixes_.begin ().base (),
t.prefixes_.end ().base ());
- if (p.context ().get<UnsignedLong> ("effective-min") != 0)
+ if (p.context ().get<size_t> ("effective-min") != 0)
min = 1;
}
}
@@ -266,11 +268,11 @@ namespace CXX
private:
Particles prefixes_;
- UnsignedLong& all_;
- UnsignedLong& choice_;
- UnsignedLong& sequence_;
+ size_t& all_;
+ size_t& choice_;
+ size_t& sequence_;
- UnsignedLong& depth_;
+ size_t& depth_;
};
@@ -278,12 +280,12 @@ namespace CXX
//
struct Complex: Traversal::Complex
{
- virtual Void
+ virtual void
traverse (Type& c)
{
if (c.contains_compositor_p ())
{
- UnsignedLong all (0), choice (0), sequence (0), depth (0);
+ size_t all (0), choice (0), sequence (0), depth (0);
Particle t (all, choice, sequence, depth);
t.dispatch (c.contains_compositor ().compositor ());
@@ -296,11 +298,11 @@ namespace CXX
};
}
- Void StateProcessor::
+ void StateProcessor::
process (SemanticGraph::Schema& tu, SemanticGraph::Path const&)
{
Traversal::Schema schema;
- Traversal::Sources sources;
+ Sources sources;
Traversal::Names schema_names;
Traversal::Namespace ns;
Traversal::Names ns_names;
diff --git a/xsd/xsd/cxx/parser/state-processor.hxx b/xsd/xsd/cxx/parser/state-processor.hxx
index 630ac13..de5af69 100644
--- a/xsd/xsd/cxx/parser/state-processor.hxx
+++ b/xsd/xsd/cxx/parser/state-processor.hxx
@@ -1,24 +1,22 @@
// file : xsd/cxx/parser/state-processor.hxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2006-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2006-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#ifndef CXX_PARSER_STATE_PROCESSOR_HXX
#define CXX_PARSER_STATE_PROCESSOR_HXX
-#include <cult/types.hxx>
#include <xsd-frontend/semantic-graph.hxx>
+#include <types.hxx>
+
namespace CXX
{
namespace Parser
{
- using namespace Cult::Types;
-
class StateProcessor
{
public:
- Void
+ void
process (XSDFrontend::SemanticGraph::Schema&,
XSDFrontend::SemanticGraph::Path const& file);
};
diff --git a/xsd/xsd/cxx/parser/type-processor.cxx b/xsd/xsd/cxx/parser/type-processor.cxx
index 4744c0a..2f1132c 100644
--- a/xsd/xsd/cxx/parser/type-processor.cxx
+++ b/xsd/xsd/cxx/parser/type-processor.cxx
@@ -1,9 +1,8 @@
// file : xsd/cxx/parser/type-processor.cxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2006-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2006-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
-#include <cult/containers/set.hxx>
+#include <set>
#include <cxx/parser/elements.hxx>
#include <cxx/parser/type-processor.hxx>
@@ -11,16 +10,12 @@
#include <xsd-frontend/semantic-graph.hxx>
#include <xsd-frontend/traversal.hxx>
+using namespace std;
+
namespace CXX
{
namespace Parser
{
- TypeProcessor::
- TypeProcessor ()
- {
- // Dummy ctor, helps with long symbols on HP-UX.
- }
-
namespace
{
//
@@ -29,14 +24,14 @@ namespace CXX
{
Type (SemanticGraph::Schema& schema,
TypeMap::Namespaces& type_map,
- Boolean add_includes)
+ bool add_includes)
: schema_ (schema),
type_map_ (type_map),
add_includes_ (add_includes)
{
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Type& type)
{
using TypeMap::Namespace;
@@ -54,7 +49,7 @@ namespace CXX
// match the type in order to add include directives to the
// new root schema.
//
- Boolean set (true);
+ bool set (true);
if (tc.count ("ret-type"))
{
@@ -73,14 +68,14 @@ namespace CXX
String ns_name (ns.name ());
String t_name (type.name ());
- // std::wcerr << "traversing: " << ns_name << "#" << t_name << endl;
+ //std::wcerr << "traversing: " << ns_name << "#" << t_name << endl;
- for (Namespaces::ConstIterator n (type_map_.begin ());
+ for (Namespaces::const_iterator n (type_map_.begin ());
n != type_map_.end (); ++n)
{
// Check if the namespace matches.
//
- Boolean ns_match;
+ bool ns_match;
if (!n->xsd_name ().empty ())
{
@@ -89,7 +84,9 @@ namespace CXX
else
ns_match = ns_name.empty ();
- // std::wcerr << "considering ns expr: " << n->xsd_name () << endl;
+ //std::wcerr << "considering ns expr: " << n->xsd_name ()
+ // << " for " << ns_name
+ // << ": " << (ns_match ? "+" : "-") << endl;
if (ns_match)
{
@@ -111,8 +108,8 @@ namespace CXX
{
if (!n->xsd_name ().empty ())
{
- cxx_ns = n->xsd_name ().merge (
- n->cxx_name (), ns_name, true);
+ cxx_ns = n->xsd_name ().replace (
+ ns_name, n->cxx_name (), true);
}
else
cxx_ns = n->cxx_name ();
@@ -124,16 +121,16 @@ namespace CXX
//
String ret_type (cxx_ns);
- ret_type += t->xsd_name ().merge (
- t->cxx_ret_name (), t_name, true);
+ ret_type += t->xsd_name ().replace (
+ t_name, t->cxx_ret_name (), true);
String arg_type;
if (t->cxx_arg_name ())
{
arg_type = cxx_ns;
- arg_type += t->xsd_name ().merge (
- t->cxx_arg_name (), t_name, true);
+ arg_type += t->xsd_name ().replace (
+ t_name, t->cxx_arg_name (), true);
}
else
{
@@ -141,7 +138,7 @@ namespace CXX
arg_type = ret_type;
else
{
- WideChar last (ret_type[ret_type.size () - 1]);
+ wchar_t last (ret_type[ret_type.size () - 1]);
// If it is already a pointer or reference then use
// it as is.
@@ -155,12 +152,12 @@ namespace CXX
tc.set ("ret-type", ret_type);
tc.set ("arg-type", arg_type);
+
+ //std::wcerr << t_name << " -> " << ret_type << endl;
}
tc.set ("root-schema", &schema_);
- //std::wcerr << t_name << " -> " << ret_type << endl;
-
// See of we need to add any includes to the translations
// unit.
//
@@ -168,7 +165,7 @@ namespace CXX
{
if (n->includes_begin () != n->includes_end ())
{
- typedef Cult::Containers::Set<String> Includes;
+ typedef std::set<String> Includes;
if (!schema_.context ().count ("includes"))
schema_.context ().set ("includes", Includes ());
@@ -194,7 +191,7 @@ namespace CXX
private:
SemanticGraph::Schema& schema_;
TypeMap::Namespaces& type_map_;
- Boolean add_includes_;
+ bool add_includes_;
};
@@ -207,7 +204,7 @@ namespace CXX
{
GlobalType (SemanticGraph::Schema& schema,
TypeMap::Namespaces& type_map,
- Boolean add_includes)
+ bool add_includes)
: type_ (schema, type_map, add_includes)
{
inherits_ >> type_;
@@ -215,20 +212,20 @@ namespace CXX
argumented_ >> type_;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Type& t)
{
type_.traverse (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::List& l)
{
type_.traverse (l);
Traversal::List::argumented (l, argumented_);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Complex& c)
{
type_.traverse (c);
@@ -236,7 +233,7 @@ namespace CXX
Complex::names (c, names_);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Enumeration& e)
{
type_.traverse (e);
@@ -252,10 +249,10 @@ namespace CXX
Traversal::Argumented argumented_;
};
- Void
- process_impl (CLI::Options const& options,
+ void
+ process_impl (options const& ops,
XSDFrontend::SemanticGraph::Schema& tu,
- Boolean gen_driver,
+ bool gen_driver,
TypeMap::Namespaces& type_map)
{
if (tu.names_begin ()->named ().name () ==
@@ -279,14 +276,13 @@ namespace CXX
// If --extern-xml-schema is specified, then we don't want
// includes from the XML Schema type map.
//
- Boolean extern_xml_schema (
- options.value<CLI::extern_xml_schema> ());
+ bool extern_xml_schema (ops.extern_xml_schema ());
//
//
Traversal::Schema schema;
Traversal::Schema xs_schema;
- Traversal::Sources sources;
+ Sources sources;
Traversal::Implies implies;
schema >> sources >> schema;
@@ -312,7 +308,7 @@ namespace CXX
// If we are generating the test driver, make sure the root
// element type is processed.
//
- if (gen_driver && options.value<CLI::generate_test_driver> ())
+ if (gen_driver && ops.generate_test_driver ())
{
// Figure out the root element. Validator should have made sure
// it is unique.
@@ -320,14 +316,14 @@ namespace CXX
SemanticGraph::Element* root (0);
{
Traversal::Schema schema;
- Traversal::Sources sources;
+ Sources sources;
schema >> sources >> schema;
Traversal::Names schema_names;
Traversal::Namespace ns;
Traversal::Names ns_names;
- RootElement root_element (options, root);
+ RootElement root_element (ops, root);
schema >> schema_names >> ns >> ns_names >> root_element;
@@ -340,13 +336,13 @@ namespace CXX
}
}
- Void TypeProcessor::
- process (CLI::Options const& options,
+ void TypeProcessor::
+ process (options const& ops,
XSDFrontend::SemanticGraph::Schema& s,
- Boolean gen_driver,
+ bool gen_driver,
TypeMap::Namespaces& tm)
{
- process_impl (options, s, gen_driver, tm);
+ process_impl (ops, s, gen_driver, tm);
}
}
}
diff --git a/xsd/xsd/cxx/parser/type-processor.hxx b/xsd/xsd/cxx/parser/type-processor.hxx
index 02a090f..634bc14 100644
--- a/xsd/xsd/cxx/parser/type-processor.hxx
+++ b/xsd/xsd/cxx/parser/type-processor.hxx
@@ -1,34 +1,29 @@
// file : xsd/cxx/parser/type-processor.hxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2006-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2006-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#ifndef CXX_PARSER_TYPE_PROCESSOR_HXX
#define CXX_PARSER_TYPE_PROCESSOR_HXX
-#include <cult/types.hxx>
-
#include <xsd-frontend/semantic-graph.hxx>
+#include <types.hxx>
+
#include <type-map/type-map.hxx>
-#include <cxx/parser/cli.hxx>
+#include <cxx/parser/options.hxx>
namespace CXX
{
namespace Parser
{
- using namespace Cult::Types;
-
class TypeProcessor
{
public:
- TypeProcessor (); // Dummy ctor, helps with long symbols on HP-UX.
-
- Void
- process (CLI::Options const& options,
+ void
+ process (options const&,
XSDFrontend::SemanticGraph::Schema&,
- Boolean gen_driver,
+ bool gen_driver,
TypeMap::Namespaces&);
};
}
diff --git a/xsd/xsd/cxx/parser/validator.cxx b/xsd/xsd/cxx/parser/validator.cxx
index 19b15c6..da9f8b0 100644
--- a/xsd/xsd/cxx/parser/validator.cxx
+++ b/xsd/xsd/cxx/parser/validator.cxx
@@ -1,8 +1,10 @@
// file : xsd/cxx/parser/validator.cxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+#include <set>
+#include <iostream>
+
#include <cxx/parser/validator.hxx>
#include <xsd-frontend/semantic-graph.hxx>
@@ -10,9 +12,7 @@
#include <cxx/parser/elements.hxx>
-#include <iostream>
-
-using std::wcerr;
+using namespace std;
namespace CXX
{
@@ -25,10 +25,10 @@ namespace CXX
public:
ValidationContext (SemanticGraph::Schema& root,
SemanticGraph::Path const& path,
- CLI::Options const& options,
+ Parser::options const& ops,
const WarningSet& disabled_warnings,
- Boolean& valid_)
- : Context (std::wcerr, root, path, options, 0, 0, 0, 0),
+ bool& valid_)
+ : Context (std::wcerr, root, path, ops, 0, 0, 0, 0),
disabled_warnings_ (disabled_warnings),
disabled_warnings_all_ (false),
valid (valid_),
@@ -38,8 +38,8 @@ namespace CXX
}
public:
- Boolean
- is_disabled (Char const* w)
+ bool
+ is_disabled (char const* w)
{
return disabled_warnings_all_ ||
disabled_warnings_.find (w) != disabled_warnings_.end ();
@@ -74,10 +74,10 @@ namespace CXX
protected:
const WarningSet& disabled_warnings_;
- Boolean disabled_warnings_all_;
- Boolean& valid;
- Boolean& subst_group_warning_issued;
- Boolean subst_group_warning_issued_;
+ bool disabled_warnings_all_;
+ bool& valid;
+ bool& subst_group_warning_issued;
+ bool subst_group_warning_issued_;
};
//
@@ -98,20 +98,20 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Element& e)
{
if (skip (e)) return;
using SemanticGraph::Any;
- Boolean q (e.qualified_p ());
+ bool q (e.qualified_p ());
String ns (q ? e.namespace_ ().name () : "");
for (Any::NamespaceIterator i (any_.namespace_begin ());
i != any_.namespace_end (); ++i)
{
- Boolean failed (false);
+ bool failed (false);
if (*i == L"##any")
{
@@ -184,14 +184,14 @@ namespace CXX
{
}
- virtual Void
+ virtual void
post (Type& c)
{
// Go down the inheritance hierarchy.
//
if (down_)
{
- Boolean up = up_;
+ bool up = up_;
up_ = false;
if (c.inherits_p ())
@@ -204,7 +204,7 @@ namespace CXX
//
if (up_)
{
- Boolean down = down_;
+ bool down = down_;
down_ = false;
for (Type::BegetsIterator i (c.begets_begin ());
@@ -218,10 +218,10 @@ namespace CXX
}
private:
- Boolean up_, down_;
+ bool up_, down_;
};
- virtual Void
+ virtual void
traverse (SemanticGraph::Any& a)
{
using SemanticGraph::Compositor;
@@ -273,7 +273,7 @@ namespace CXX
}
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Complex& c)
{
using SemanticGraph::Schema;
@@ -319,7 +319,7 @@ namespace CXX
Complex::traverse (c);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Type& t)
{
if (t.named_p ())
@@ -328,14 +328,14 @@ namespace CXX
}
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Element& e)
{
if (is_disabled ("P002"))
return;
if (e.substitutes_p () &&
- !options.value<CLI::generate_polymorphic> () &&
+ !options.generate_polymorphic () &&
!subst_group_warning_issued)
{
subst_group_warning_issued = true;
@@ -352,7 +352,7 @@ namespace CXX
// Return true if root sources s.
//
- Boolean
+ bool
sources_p (SemanticGraph::Schema& root, SemanticGraph::Schema& s)
{
using SemanticGraph::Schema;
@@ -372,9 +372,9 @@ namespace CXX
}
private:
- Containers::Set<String> types_;
+ set<String> types_;
- Traversal::Sources sources_;
+ Sources sources_;
Traversal::Names schema_names_;
Traversal::Namespace ns_;
@@ -405,7 +405,7 @@ namespace CXX
*this >> names_;
}
- Boolean
+ bool
traverse_common (SemanticGraph::Member& m)
{
SemanticGraph::Type& t (m.type ());
@@ -434,7 +434,7 @@ namespace CXX
<< "automatically name them"
<< endl;
- if (!options.value<CLI::show_anonymous> ())
+ if (!options.show_anonymous ())
wcerr << t.file ()
<< ": info: use --show-anonymous option to see these "
<< "types" << endl;
@@ -446,14 +446,14 @@ namespace CXX
return false;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Element& e)
{
if (skip (e)) return;
if (traverse_common (e))
{
- if (options.value<CLI::show_anonymous> ())
+ if (options.show_anonymous ())
{
wcerr << e.file () << ":" << e.line () << ":" << e.column ()
<< ": error: element '" << xpath (e) << "' "
@@ -464,12 +464,12 @@ namespace CXX
Traversal::Element::traverse (e);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Attribute& a)
{
if (traverse_common (a))
{
- if (options.value<CLI::show_anonymous> ())
+ if (options.show_anonymous ())
{
wcerr << a.file () << ":" << a.line () << ":" << a.column ()
<< ": error: attribute '" << xpath (a) << "' "
@@ -481,11 +481,11 @@ namespace CXX
}
private:
- Boolean anonymous_error_issued_;
+ bool anonymous_error_issued_;
- Containers::Set<String> types_;
+ set<String> types_;
- Traversal::Sources sources_;
+ Sources sources_;
Traversal::Names schema_names_;
Traversal::Namespace ns_;
@@ -500,22 +500,22 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& e)
{
if (!valid)
return;
- if (options.value<CLI::root_element_first> ())
+ if (options.root_element_first ())
{
if (element_ == 0)
element_ = &e;
}
- else if (options.value<CLI::root_element_last> ())
+ else if (options.root_element_last ())
{
element_ = &e;
}
- else if (String name = options.value<CLI::root_element> ())
+ else if (String name = options.root_element ())
{
if (e.name () == name)
element_ = &e;
@@ -544,46 +544,40 @@ namespace CXX
}
- Validator::
- Validator ()
- {
- // Dummy ctor, helps with long symbols on HP-UX.
- }
-
- Boolean Validator::
- validate (CLI::Options const& options,
+ bool Validator::
+ validate (options const& ops,
SemanticGraph::Schema& root,
SemanticGraph::Path const& path,
- Boolean gen_driver,
+ bool gen_driver,
const WarningSet& disabled_warnings)
{
- Boolean valid (true);
- ValidationContext ctx (root, path, options, disabled_warnings, valid);
+ bool valid (true);
+ ValidationContext ctx (root, path, ops, disabled_warnings, valid);
//
//
- if (options.value<CLI::char_type> () != "char" &&
- options.value<CLI::char_type> () != "wchar_t" &&
+ if (ops.char_type () != "char" &&
+ ops.char_type () != "wchar_t" &&
!ctx.is_disabled ("P003"))
{
wcerr << "warning P003: unknown base character type '" <<
- options.value<CLI::char_type> ().c_str () << "'" << endl;
+ ops.char_type ().c_str () << "'" << endl;
}
//
//
- if (options.value<CLI::xml_parser> () != "xerces" &&
- options.value<CLI::xml_parser> () != "expat" &&
+ if (ops.xml_parser () != "xerces" &&
+ ops.xml_parser () != "expat" &&
!ctx.is_disabled ("P004"))
{
wcerr << "warning P004: unknown underlying XML parser '" <<
- options.value<CLI::xml_parser> ().c_str () << "'" << endl;
+ ops.xml_parser ().c_str () << "'" << endl;
}
//
//
- if (options.value<CLI::xml_parser> () == "expat" &&
- options.value<CLI::char_type> () == "wchar_t")
+ if (ops.xml_parser () == "expat" &&
+ ops.char_type () == "wchar_t")
{
wcerr << "error: using expat with wchar_t is not supported"
<< endl;
@@ -593,9 +587,9 @@ namespace CXX
//
//
- if (options.value<CLI::xml_parser> () == "expat" &&
- !options.value<CLI::char_encoding> ().empty () &&
- options.value<CLI::char_encoding> () != "utf8")
+ if (ops.xml_parser () == "expat" &&
+ !ops.char_encoding ().empty () &&
+ ops.char_encoding () != "utf8")
{
wcerr << "error: using expat with character encoding other than "
<< "utf8 is not supported"
@@ -606,8 +600,7 @@ namespace CXX
//
//
- if (options.value<CLI::generate_validation> () &&
- options.value<CLI::suppress_validation> ())
+ if (ops.generate_validation () && ops.suppress_validation ())
{
wcerr << "error: mutually exclusive options specified: "
<< "--generate-validation and --suppress-validation"
@@ -618,8 +611,7 @@ namespace CXX
//
//
- if (options.value<CLI::generate_noop_impl> () &&
- options.value<CLI::generate_print_impl> ())
+ if (ops.generate_noop_impl () && ops.generate_print_impl ())
{
wcerr << "error: mutually exclusive options specified: "
<< "--generate-noop-impl and --generate-print-impl"
@@ -631,9 +623,9 @@ namespace CXX
//
//
{
- Boolean ref (options.value<CLI::root_element_first> ());
- Boolean rel (options.value<CLI::root_element_last> ());
- Boolean re (options.value<CLI::root_element> ());
+ bool ref (ops.root_element_first ());
+ bool rel (ops.root_element_last ());
+ bool re (ops.root_element ());
if ((ref && rel) || (ref && re) || (rel && re))
{
@@ -648,8 +640,8 @@ namespace CXX
//
//
- Boolean import_maps (options.value<CLI::import_maps> ());
- Boolean export_maps (options.value<CLI::export_maps> ());
+ bool import_maps (ops.import_maps ());
+ bool export_maps (ops.export_maps ());
if (import_maps && export_maps)
{
@@ -698,7 +690,7 @@ namespace CXX
SemanticGraph::Element* element (0);
Traversal::Schema schema;
- Traversal::Sources sources;
+ Sources sources;
schema >> sources >> schema;
diff --git a/xsd/xsd/cxx/parser/validator.hxx b/xsd/xsd/cxx/parser/validator.hxx
index f519b05..c67cced 100644
--- a/xsd/xsd/cxx/parser/validator.hxx
+++ b/xsd/xsd/cxx/parser/validator.hxx
@@ -1,32 +1,28 @@
// file : xsd/cxx/parser/validator.hxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#ifndef CXX_PARSER_VALIDATOR_HXX
#define CXX_PARSER_VALIDATOR_HXX
-#include <cxx/parser/elements.hxx>
-#include <cxx/parser/cli.hxx>
-
#include <xsd.hxx>
+#include <types.hxx>
+
+#include <cxx/parser/elements.hxx>
+#include <cxx/parser/options.hxx>
namespace CXX
{
namespace Parser
{
- using namespace Cult::Types;
-
class Validator
{
public:
- Validator (); // Dummy ctor, helps with long symbols on HP-UX.
-
- Boolean
- validate (CLI::Options const& options,
+ bool
+ validate (options const&,
SemanticGraph::Schema&,
SemanticGraph::Path const& tu,
- Boolean gen_driver,
+ bool gen_driver,
const WarningSet& disabled_warnings);
};
}
diff --git a/xsd/xsd/cxx/tree/cli.hxx b/xsd/xsd/cxx/tree/cli.hxx
deleted file mode 100644
index 171711d..0000000
--- a/xsd/xsd/cxx/tree/cli.hxx
+++ /dev/null
@@ -1,228 +0,0 @@
-// file : xsd/cxx/tree/cli.hxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
-// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
-
-#ifndef CXX_TREE_CLI_HXX
-#define CXX_TREE_CLI_HXX
-
-#include <cult/types.hxx>
-
-#include <cult/containers/vector.hxx>
-
-#include <cult/cli/options.hxx>
-#include <cult/cli/options-spec.hxx>
-
-namespace CXX
-{
- namespace Tree
- {
- namespace CLI
- {
- using namespace Cult::Types;
-
- typedef Char const Key[];
-
- extern Key char_type;
- extern Key char_encoding;
- extern Key output_dir;
- extern Key generate_polymorphic;
- extern Key polymorphic_type;
- extern Key polymorphic_type_all;
- extern Key generate_serialization;
- extern Key generate_inline;
- extern Key generate_ostream;
- extern Key generate_doxygen;
- extern Key generate_comparison;
- extern Key generate_default_ctor;
- extern Key generate_from_base_ctor;
- extern Key generate_detach;
- extern Key generate_wildcard;
- extern Key generate_insertion;
- extern Key generate_extraction;
- extern Key generate_forward;
- extern Key generate_xml_schema;
- extern Key extern_xml_schema;
- extern Key suppress_parsing;
- extern Key generate_element_type;
- extern Key generate_element_map;
- extern Key generate_intellisense;
- extern Key omit_default_attributes;
- extern Key namespace_map;
- extern Key namespace_regex;
- extern Key namespace_regex_trace;
- extern Key reserved_name;
- extern Key type_naming;
- extern Key function_naming;
- extern Key type_regex;
- extern Key accessor_regex;
- extern Key one_accessor_regex;
- extern Key opt_accessor_regex;
- extern Key seq_accessor_regex;
- extern Key modifier_regex;
- extern Key one_modifier_regex;
- extern Key opt_modifier_regex;
- extern Key seq_modifier_regex;
- extern Key parser_regex;
- extern Key serializer_regex;
- extern Key enumerator_regex;
- extern Key element_type_regex;
- extern Key name_regex_trace;
- extern Key include_with_brackets;
- extern Key include_prefix;
- extern Key include_regex;
- extern Key include_regex_trace;
- extern Key guard_prefix;
- extern Key root_element_first;
- extern Key root_element_last;
- extern Key root_element_all;
- extern Key root_element_none;
- extern Key root_element;
- extern Key custom_type;
- extern Key custom_type_regex;
- extern Key hxx_suffix;
- extern Key ixx_suffix;
- extern Key cxx_suffix;
- extern Key fwd_suffix;
- extern Key hxx_regex;
- extern Key ixx_regex;
- extern Key cxx_regex;
- extern Key fwd_regex;
- extern Key hxx_prologue;
- extern Key ixx_prologue;
- extern Key cxx_prologue;
- extern Key fwd_prologue;
- extern Key prologue;
- extern Key hxx_epilogue;
- extern Key ixx_epilogue;
- extern Key cxx_epilogue;
- extern Key fwd_epilogue;
- extern Key epilogue;
- extern Key hxx_prologue_file;
- extern Key ixx_prologue_file;
- extern Key cxx_prologue_file;
- extern Key fwd_prologue_file;
- extern Key prologue_file;
- extern Key hxx_epilogue_file;
- extern Key ixx_epilogue_file;
- extern Key cxx_epilogue_file;
- extern Key fwd_epilogue_file;
- extern Key epilogue_file;
- extern Key parts;
- extern Key parts_suffix;
- extern Key export_symbol;
- extern Key export_xml_schema;
- extern Key export_maps;
- extern Key import_maps;
- extern Key show_anonymous;
- extern Key show_sloc;
- extern Key proprietary_license;
- extern Key disable_multi_import; // Undocumented.
-
-
- typedef Cult::CLI::Options<
-
- char_type, NarrowString,
- char_encoding, NarrowString,
- output_dir, NarrowString,
- generate_polymorphic, Boolean,
- polymorphic_type, Cult::Containers::Vector<NarrowString>,
- polymorphic_type_all, Boolean,
- generate_serialization, Boolean,
- generate_inline, Boolean,
- generate_ostream, Boolean,
- generate_doxygen, Boolean,
- generate_comparison, Boolean,
- generate_default_ctor, Boolean,
- generate_from_base_ctor, Boolean,
- generate_detach, Boolean,
- generate_wildcard, Boolean,
- generate_insertion, Cult::Containers::Vector<NarrowString>,
- generate_extraction, Cult::Containers::Vector<NarrowString>,
- generate_forward, Boolean,
- generate_xml_schema, Boolean,
- extern_xml_schema, NarrowString,
- suppress_parsing, Boolean,
- generate_element_type, Boolean,
- generate_element_map, Boolean,
- generate_intellisense, Boolean,
- omit_default_attributes, Boolean,
- namespace_map, Cult::Containers::Vector<NarrowString>,
- namespace_regex, Cult::Containers::Vector<NarrowString>,
- namespace_regex_trace, Boolean,
- reserved_name, Cult::Containers::Vector<NarrowString>,
- type_naming, NarrowString,
- function_naming, NarrowString,
- type_regex, Cult::Containers::Vector<NarrowString>,
- accessor_regex, Cult::Containers::Vector<NarrowString>,
- one_accessor_regex, Cult::Containers::Vector<NarrowString>,
- opt_accessor_regex, Cult::Containers::Vector<NarrowString>,
- seq_accessor_regex, Cult::Containers::Vector<NarrowString>,
- modifier_regex, Cult::Containers::Vector<NarrowString>,
- one_modifier_regex, Cult::Containers::Vector<NarrowString>,
- opt_modifier_regex, Cult::Containers::Vector<NarrowString>,
- seq_modifier_regex, Cult::Containers::Vector<NarrowString>,
- parser_regex, Cult::Containers::Vector<NarrowString>,
- serializer_regex, Cult::Containers::Vector<NarrowString>,
- enumerator_regex, Cult::Containers::Vector<NarrowString>,
- element_type_regex, Cult::Containers::Vector<NarrowString>,
- name_regex_trace, Boolean,
- include_with_brackets, Boolean,
- include_prefix, NarrowString,
- include_regex, Cult::Containers::Vector<NarrowString>,
- include_regex_trace, Boolean,
- guard_prefix, NarrowString,
- root_element_first, Boolean,
- root_element_last, Boolean,
- root_element_all, Boolean,
- root_element_none, Boolean,
- root_element, Cult::Containers::Vector<NarrowString>,
- custom_type, Cult::Containers::Vector<NarrowString>,
- custom_type_regex, Cult::Containers::Vector<NarrowString>,
- hxx_suffix, NarrowString,
- ixx_suffix, NarrowString,
- cxx_suffix, NarrowString,
- fwd_suffix, NarrowString,
- hxx_regex, NarrowString,
- ixx_regex, NarrowString,
- cxx_regex, NarrowString,
- fwd_regex, NarrowString,
- hxx_prologue, Cult::Containers::Vector<NarrowString>,
- ixx_prologue, Cult::Containers::Vector<NarrowString>,
- cxx_prologue, Cult::Containers::Vector<NarrowString>,
- fwd_prologue, Cult::Containers::Vector<NarrowString>,
- prologue, Cult::Containers::Vector<NarrowString>,
- hxx_epilogue, Cult::Containers::Vector<NarrowString>,
- ixx_epilogue, Cult::Containers::Vector<NarrowString>,
- cxx_epilogue, Cult::Containers::Vector<NarrowString>,
- fwd_epilogue, Cult::Containers::Vector<NarrowString>,
- epilogue, Cult::Containers::Vector<NarrowString>,
- hxx_prologue_file, NarrowString,
- ixx_prologue_file, NarrowString,
- cxx_prologue_file, NarrowString,
- fwd_prologue_file, NarrowString,
- prologue_file, NarrowString,
- hxx_epilogue_file, NarrowString,
- ixx_epilogue_file, NarrowString,
- cxx_epilogue_file, NarrowString,
- fwd_epilogue_file, NarrowString,
- epilogue_file, NarrowString,
- parts, UnsignedLong,
- parts_suffix, NarrowString,
- export_symbol, NarrowString,
- export_xml_schema, Boolean,
- export_maps, Boolean,
- import_maps, Boolean,
- show_anonymous, Boolean,
- show_sloc, Boolean,
- proprietary_license, Boolean,
- disable_multi_import, Boolean
-
- > Options;
-
- struct OptionsSpec: Cult::CLI::OptionsSpec<Options> {};
- }
- }
-}
-
-#endif // CXX_TREE_CLI_HXX
diff --git a/xsd/xsd/cxx/tree/counter.cxx b/xsd/xsd/cxx/tree/counter.cxx
index 9254226..23fc221 100644
--- a/xsd/xsd/cxx/tree/counter.cxx
+++ b/xsd/xsd/cxx/tree/counter.cxx
@@ -1,6 +1,5 @@
// file : xsd/cxx/tree/counter.cxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2006-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2006-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#include <cxx/tree/counter.hxx>
@@ -15,40 +14,40 @@ namespace CXX
{
struct Member: Traversal::Member
{
- Member (UnsignedLong& complexity)
+ Member (size_t& complexity)
: complexity_ (complexity)
{
}
- virtual Void
+ virtual void
traverse (Type&)
{
complexity_++;
}
- UnsignedLong& complexity_;
+ size_t& complexity_;
};
struct Any: Traversal::Any, Traversal::AnyAttribute
{
- Any (UnsignedLong& complexity)
+ Any (size_t& complexity)
: complexity_ (complexity)
{
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Any&)
{
complexity_++;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::AnyAttribute&)
{
complexity_++;
}
- UnsignedLong& complexity_;
+ size_t& complexity_;
};
struct TypeBase: Traversal::List,
@@ -57,27 +56,27 @@ namespace CXX
Traversal::Complex,
Context
{
- TypeBase (Context& c, UnsignedLong& complexity)
+ TypeBase (Context& c, size_t& complexity)
: Context (c), complexity_ (complexity)
{
}
- virtual Void
+ virtual void
traverse (SemanticGraph::List&)
{
complexity_++;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Union&)
{
complexity_++;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Enumeration& e)
{
- Boolean string_based (false);
+ bool string_based (false);
{
IsStringBasedType t (string_based);
t.dispatch (e);
@@ -86,7 +85,7 @@ namespace CXX
complexity_ += (string_based ? 1 : 2);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Complex& c)
{
complexity_++; // One for the type itself.
@@ -99,14 +98,14 @@ namespace CXX
names >> member;
- if (options.value<CLI::generate_wildcard> ())
+ if (options.generate_wildcard ())
names >> any;
Complex::names (c, names);
}
private:
- UnsignedLong& complexity_;
+ size_t& complexity_;
};
@@ -120,12 +119,12 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Type& t)
{
counts_.global_types++;
- UnsignedLong complexity (0);
+ size_t complexity (0);
TypeBase type (*this, complexity);
type.dispatch (t);
@@ -160,7 +159,7 @@ namespace CXX
}
}
- virtual Void
+ virtual void
traverse (Type& e)
{
// Check if the previous element we saw needs to be generated.
@@ -177,33 +176,33 @@ namespace CXX
}
private:
- Void
+ void
count_last ()
{
if (generate_p (*last_))
{
counts_.generated_global_elements++;
- UnsignedLong complexity (0);
+ size_t complexity (0);
if (doc_root_p (*last_))
{
- if (options.value<CLI::generate_element_type> ())
+ if (options.generate_element_type ())
{
complexity += 1; // For c-tors and d-tor.
- if (!options.value<CLI::suppress_parsing> ())
+ if (!options.suppress_parsing ())
complexity += 1;
- if (options.value<CLI::generate_serialization> ())
+ if (options.generate_serialization ())
complexity += 1;
}
else
{
- if (!options.value<CLI::suppress_parsing> ())
+ if (!options.suppress_parsing ())
complexity += 6; // 13 parsing functions.
- if (options.value<CLI::generate_serialization> ())
+ if (options.generate_serialization ())
complexity += 4; // 8 serialization functions.
}
}
@@ -230,21 +229,16 @@ namespace CXX
};
}
- Counter::
- Counter ()
- {
- }
-
Counts Counter::
- count (CLI::Options const& options,
+ count (options const& ops,
SemanticGraph::Schema& tu,
SemanticGraph::Path const& path)
{
Counts counts;
- Context ctx (std::wcerr, tu, path, options, counts, false, 0, 0, 0, 0);
+ Context ctx (std::wcerr, tu, path, ops, counts, false, 0, 0, 0, 0);
Traversal::Schema schema;
- Traversal::Sources sources;
+ Sources sources;
schema >> sources >> schema;
diff --git a/xsd/xsd/cxx/tree/counter.hxx b/xsd/xsd/cxx/tree/counter.hxx
index 726de47..ea1a3c3 100644
--- a/xsd/xsd/cxx/tree/counter.hxx
+++ b/xsd/xsd/cxx/tree/counter.hxx
@@ -1,13 +1,12 @@
// file : xsd/cxx/tree/counter.hxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2006-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2006-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#ifndef CXX_TREE_COUNTER_HXX
#define CXX_TREE_COUNTER_HXX
#include <cxx/tree/elements.hxx>
-#include <cxx/tree/cli.hxx>
+#include <cxx/tree/options.hxx>
namespace CXX
{
@@ -16,10 +15,8 @@ namespace CXX
class Counter
{
public:
- Counter (); // Dummy ctor, helps with long symbols on HP-UX.
-
Counts
- count (CLI::Options const&,
+ count (options const&,
SemanticGraph::Schema&,
SemanticGraph::Path const&);
};
diff --git a/xsd/xsd/cxx/tree/default-value.cxx b/xsd/xsd/cxx/tree/default-value.cxx
index ff964d3..4f27d7f 100644
--- a/xsd/xsd/cxx/tree/default-value.cxx
+++ b/xsd/xsd/cxx/tree/default-value.cxx
@@ -1,11 +1,11 @@
// file : xsd/cxx/tree/default-value.cxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#include <cxx/tree/default-value.hxx>
using std::hex;
+using std::dec;
namespace CXX
{
@@ -13,14 +13,14 @@ namespace CXX
{
namespace
{
- Void
+ void
normalize (String& s)
{
- Size n (s.size ());
+ size_t n (s.size ());
- for (Size i (0); i < n; ++i)
+ for (size_t i (0); i < n; ++i)
{
- WideChar& c (s[i]);
+ wchar_t& c (s[i]);
if (c == 0x0D || // carriage return
c == 0x09 || // tab
@@ -29,15 +29,15 @@ namespace CXX
}
}
- Void
+ void
collapse (String& s)
{
- Size n (s.size ()), j (0);
- Boolean subs (false), trim (true);
+ size_t n (s.size ()), j (0);
+ bool subs (false), trim (true);
- for (Size i (0); i < n; ++i)
+ for (size_t i (0); i < n; ++i)
{
- WideChar c (s[i]);
+ wchar_t c (s[i]);
if (c == 0x20 || c == 0x09 || c == 0x0A)
subs = true;
@@ -61,21 +61,21 @@ namespace CXX
s.resize (j);
}
- Void
+ void
strip_zeros (String& s)
{
- Size n (s.size ()), i (0);
+ size_t n (s.size ()), i (0);
if (n > 0 && (s[i] == '-' || s[i] == '+'))
i++;
- Size j (i);
+ size_t j (i);
- Boolean strip (true);
+ bool strip (true);
for (; i < n; ++i)
{
- WideChar c (s[i]);
+ wchar_t c (s[i]);
if (c == '0')
{
@@ -97,7 +97,7 @@ namespace CXX
s.resize (j);
}
- Void
+ void
make_float (String& s)
{
if (s.find ('.') == String::npos &&
@@ -112,13 +112,13 @@ namespace CXX
//
IsLiteralValue::
- IsLiteralValue (Boolean& r)
+ IsLiteralValue (bool& r)
: IsFundamentalType (r)
{
*this >> inherits_ >> *this;
}
- Void IsLiteralValue::
+ void IsLiteralValue::
traverse (SemanticGraph::Complex& c)
{
inherits (c);
@@ -144,7 +144,7 @@ namespace CXX
return literal_;
}
- Void LiteralValue::
+ void LiteralValue::
traverse (SemanticGraph::Complex& c)
{
inherits (c);
@@ -152,7 +152,7 @@ namespace CXX
// Boolean.
//
- Void LiteralValue::
+ void LiteralValue::
traverse (SemanticGraph::Fundamental::Boolean&)
{
collapse (value_);
@@ -161,7 +161,7 @@ namespace CXX
// Integral types.
//
- Void LiteralValue::
+ void LiteralValue::
traverse (SemanticGraph::Fundamental::Byte&)
{
collapse (value_);
@@ -169,15 +169,15 @@ namespace CXX
literal_ = value_;
}
- Void LiteralValue::
+ void LiteralValue::
traverse (SemanticGraph::Fundamental::UnsignedByte&)
{
collapse (value_);
strip_zeros (value_);
- literal_ = value_;
+ literal_ = value_ + L"U";
}
- Void LiteralValue::
+ void LiteralValue::
traverse (SemanticGraph::Fundamental::Short&)
{
collapse (value_);
@@ -185,15 +185,15 @@ namespace CXX
literal_ = value_;
}
- Void LiteralValue::
+ void LiteralValue::
traverse (SemanticGraph::Fundamental::UnsignedShort&)
{
collapse (value_);
strip_zeros (value_);
- literal_ = value_;
+ literal_ = value_ + L"U";
}
- Void LiteralValue::
+ void LiteralValue::
traverse (SemanticGraph::Fundamental::Int&)
{
collapse (value_);
@@ -201,15 +201,15 @@ namespace CXX
literal_ = value_;
}
- Void LiteralValue::
+ void LiteralValue::
traverse (SemanticGraph::Fundamental::UnsignedInt&)
{
collapse (value_);
strip_zeros (value_);
- literal_ = value_;
+ literal_ = value_ + L"U";
}
- Void LiteralValue::
+ void LiteralValue::
traverse (SemanticGraph::Fundamental::Long&)
{
collapse (value_);
@@ -218,7 +218,7 @@ namespace CXX
literal_ += L"LL";
}
- Void LiteralValue::
+ void LiteralValue::
traverse (SemanticGraph::Fundamental::UnsignedLong&)
{
collapse (value_);
@@ -227,7 +227,7 @@ namespace CXX
literal_ += L"ULL";
}
- Void LiteralValue::
+ void LiteralValue::
traverse (SemanticGraph::Fundamental::Integer&)
{
collapse (value_);
@@ -235,7 +235,7 @@ namespace CXX
literal_ = value_ + L"LL";
}
- Void LiteralValue::
+ void LiteralValue::
traverse (SemanticGraph::Fundamental::NonPositiveInteger&)
{
collapse (value_);
@@ -243,7 +243,7 @@ namespace CXX
literal_ = value_ + L"LL";
}
- Void LiteralValue::
+ void LiteralValue::
traverse (SemanticGraph::Fundamental::NonNegativeInteger&)
{
collapse (value_);
@@ -251,7 +251,7 @@ namespace CXX
literal_ = value_ + L"ULL";
}
- Void LiteralValue::
+ void LiteralValue::
traverse (SemanticGraph::Fundamental::PositiveInteger&)
{
collapse (value_);
@@ -259,7 +259,7 @@ namespace CXX
literal_ = value_ + L"ULL";
}
- Void LiteralValue::
+ void LiteralValue::
traverse (SemanticGraph::Fundamental::NegativeInteger&)
{
collapse (value_);
@@ -269,7 +269,7 @@ namespace CXX
// Floats.
//
- Void LiteralValue::
+ void LiteralValue::
traverse (SemanticGraph::Fundamental::Float& t)
{
collapse (value_);
@@ -297,7 +297,7 @@ namespace CXX
}
}
- Void LiteralValue::
+ void LiteralValue::
traverse (SemanticGraph::Fundamental::Double& t)
{
collapse (value_);
@@ -325,7 +325,7 @@ namespace CXX
}
}
- Void LiteralValue::
+ void LiteralValue::
traverse (SemanticGraph::Fundamental::Decimal&)
{
collapse (value_);
@@ -345,43 +345,43 @@ namespace CXX
*this >> inherits_ >> *this;
}
- Void InitKind::
+ void InitKind::
traverse (SemanticGraph::List&)
{
r_ = function;
}
- Void InitKind::
+ void InitKind::
traverse (SemanticGraph::Complex& c)
{
inherits (c);
}
- Void InitKind::
+ void InitKind::
traverse (SemanticGraph::Fundamental::Base64Binary&)
{
r_ = data;
}
- Void InitKind::
+ void InitKind::
traverse (SemanticGraph::Fundamental::HexBinary&)
{
r_ = data;
}
- Void InitKind::
+ void InitKind::
traverse (SemanticGraph::Fundamental::NameTokens&)
{
r_ = function;
}
- Void InitKind::
+ void InitKind::
traverse (SemanticGraph::Fundamental::IdRefs&)
{
r_ = function;
}
- Void InitKind::
+ void InitKind::
traverse (SemanticGraph::Fundamental::Entities&)
{
r_ = function;
@@ -397,14 +397,14 @@ namespace CXX
{
}
- Void InitValue::
+ void InitValue::
dispatch (SemanticGraph::Node& type, String const& value)
{
value_ = value;
Traversal::NodeBase::dispatch (type);
}
- Void InitValue::
+ void InitValue::
traverse (SemanticGraph::List& l)
{
collapse (value_);
@@ -415,9 +415,9 @@ namespace CXX
SemanticGraph::Type& t (l.argumented ().type ());
String ov (value_);
- Size b (0);
+ size_t b (0);
- for (Size e (ov.find (' ')); ; e = ov.find (' ', b))
+ for (size_t e (ov.find (' ')); ; e = ov.find (' ', b))
{
String v (ov, b, e != String::npos ? e - b : e);
@@ -448,21 +448,27 @@ namespace CXX
value_ = ov;
}
- Void InitValue::
+ void InitValue::
traverse (SemanticGraph::Union&)
{
os << strlit (value_);
}
- Void InitValue::
+ void InitValue::
traverse (SemanticGraph::Complex& c)
{
Traversal::NodeBase::dispatch (ultimate_base (c));
}
- // anySimpleType.
+ // anyType & anySimpleType.
//
- Void InitValue::
+ void InitValue::
+ traverse (SemanticGraph::AnyType& t)
+ {
+ os << fq_name (t) << " (" << strlit (value_) << ")";
+ }
+
+ void InitValue::
traverse (SemanticGraph::AnySimpleType& t)
{
os << fq_name (t) << " (" << strlit (value_) << ")";
@@ -470,34 +476,34 @@ namespace CXX
// Strings.
//
- Void InitValue::
+ void InitValue::
traverse (SemanticGraph::Fundamental::String&)
{
os << strlit (value_);
}
- Void InitValue::
+ void InitValue::
traverse (SemanticGraph::Fundamental::NormalizedString&)
{
normalize (value_);
os << strlit (value_);
}
- Void InitValue::
+ void InitValue::
traverse (SemanticGraph::Fundamental::Token&)
{
collapse (value_);
os << strlit (value_);
}
- Void InitValue::
+ void InitValue::
traverse (SemanticGraph::Fundamental::NameToken&)
{
collapse (value_);
os << strlit (value_);
}
- Void InitValue::
+ void InitValue::
traverse (SemanticGraph::Fundamental::NameTokens&)
{
string_sequence_type (
@@ -505,21 +511,21 @@ namespace CXX
xs_ns ().find ("NMTOKEN").first->named ()));
}
- Void InitValue::
+ void InitValue::
traverse (SemanticGraph::Fundamental::Name&)
{
collapse (value_);
os << strlit (value_);
}
- Void InitValue::
+ void InitValue::
traverse (SemanticGraph::Fundamental::NCName&)
{
collapse (value_);
os << strlit (value_);
}
- Void InitValue::
+ void InitValue::
traverse (SemanticGraph::Fundamental::Language&)
{
collapse (value_);
@@ -528,10 +534,10 @@ namespace CXX
// Qualified name.
//
- Void InitValue::
+ void InitValue::
traverse (SemanticGraph::Fundamental::QName& t)
{
- Size p (value_.rfind ('#'));
+ size_t p (value_.rfind ('#'));
if (p != String::npos)
{
@@ -563,21 +569,21 @@ namespace CXX
// ID/IDREF.
//
- Void InitValue::
+ void InitValue::
traverse (SemanticGraph::Fundamental::Id&)
{
collapse (value_);
os << strlit (value_);
}
- Void InitValue::
+ void InitValue::
traverse (SemanticGraph::Fundamental::IdRef&)
{
collapse (value_);
os << strlit (value_);
}
- Void InitValue::
+ void InitValue::
traverse (SemanticGraph::Fundamental::IdRefs&)
{
string_sequence_type (
@@ -587,7 +593,7 @@ namespace CXX
// URI.
//
- Void InitValue::
+ void InitValue::
traverse (SemanticGraph::Fundamental::AnyURI&)
{
collapse (value_);
@@ -615,7 +621,7 @@ namespace CXX
return r;
}
- Void InitValue::
+ void InitValue::
traverse (SemanticGraph::Fundamental::Base64Binary& t)
{
collapse (value_);
@@ -628,17 +634,17 @@ namespace CXX
// Decode.
//
- Size size (value_.size ());
+ size_t size (value_.size ());
// Remove all whitespaces.
//
{
- Size j (0);
- Boolean subs (false);
+ size_t j (0);
+ bool subs (false);
- for (Size i (0); i < size; ++i)
+ for (size_t i (0); i < size; ++i)
{
- WideChar c (value_[i]);
+ wchar_t c (value_[i]);
if (c == 0x20 || c == 0x0A || c == 0x0D || c == 0x09)
subs = true;
@@ -657,20 +663,20 @@ namespace CXX
// Our length should be a multiple of four.
//
- Size quad_count (size / 4);
+ size_t quad_count (size / 4);
// Source and destination indexes.
//
- Size si (0), di (0);
+ size_t si (0), di (0);
// Process all quads except the last one.
//
unsigned short v;
unsigned char b1, b2, b3, b4;
- WideChar prev_fill (os.fill ('0'));
+ wchar_t prev_fill (os.fill ('0'));
- for (Size q (0); q < quad_count - 1; ++q)
+ for (size_t q (0); q < quad_count - 1; ++q)
{
b1 = base64_decode (value_[si++]);
b2 = base64_decode (value_[si++]);
@@ -683,17 +689,21 @@ namespace CXX
if (di % 9 == 0)
os << endl;
+ os << hex;
+
v = static_cast<unsigned char> ((b1 << 2) | (b2 >> 4));
os.width (2);
- os << "0x" << hex << v;
+ os << "0x" << v;
v = static_cast<unsigned char> ((b2 << 4) | (b3 >> 2));
os.width (2);
- os << ", 0x" << hex << v;
+ os << ", 0x" << v;
v = static_cast<unsigned char> ((b3 << 6) | b4);
os.width (2);
- os << ", 0x" << hex << v;
+ os << ", 0x" << v;
+
+ os << dec;
di += 3;
}
@@ -703,7 +713,7 @@ namespace CXX
b1 = base64_decode (value_[si++]);
b2 = base64_decode (value_[si++]);
- WideChar e3 (value_[si++]), e4 (value_[si++]);
+ wchar_t e3 (value_[si++]), e4 (value_[si++]);
if (quad_count != 1)
os << ", ";
@@ -718,7 +728,7 @@ namespace CXX
// Two pads. Last 4 bits in b2 should be zero.
//
v = static_cast<unsigned char> ((b1 << 2) | (b2 >> 4));
- os << "0x" << hex << v;
+ os << "0x" << hex << v << dec;
di++;
}
else
@@ -727,13 +737,17 @@ namespace CXX
//
b3 = base64_decode (e3);
+ os << hex;
+
v = static_cast<unsigned char> ((b1 << 2) | (b2 >> 4));
os.width (2);
- os << "0x" << hex << v;
+ os << "0x" << v;
v = static_cast<unsigned char> ((b2 << 4) | (b3 >> 2));
os.width (2);
- os << ", 0x" << hex << v;
+ os << ", 0x" << v;
+
+ os << dec;
di += 2;
}
@@ -745,17 +759,21 @@ namespace CXX
b3 = base64_decode (e3);
b4 = base64_decode (e4);
+ os << hex;
+
v = static_cast<unsigned char> ((b1 << 2) | (b2 >> 4));
os.width (2);
- os << "0x" << hex << v;
+ os << "0x" << v;
v = static_cast<unsigned char> ((b2 << 4) | (b3 >> 2));
os.width (2);
- os << ", 0x" << hex << v;
+ os << ", 0x" << v;
v = static_cast<unsigned char> ((b3 << 6) | b4);
os.width (2);
- os << ", 0x" << hex << v;
+ os << ", 0x" << v;
+
+ os << dec;
di += 3;
}
@@ -797,7 +815,7 @@ namespace CXX
return r;
}
- Void InitValue::
+ void InitValue::
traverse (SemanticGraph::Fundamental::HexBinary& t)
{
collapse (value_);
@@ -810,10 +828,10 @@ namespace CXX
// Decode.
//
- Size n (value_.size () / 2);
- WideChar prev_fill (os.fill ('0'));
+ size_t n (value_.size () / 2);
+ wchar_t prev_fill (os.fill ('0'));
- for (Size i (0); i < n; ++i)
+ for (size_t i (0); i < n; ++i)
{
unsigned char h (hex_decode (value_[2 * i]));
unsigned char l (hex_decode (value_[2 * i + 1]));
@@ -829,7 +847,7 @@ namespace CXX
unsigned short v = static_cast<unsigned char> ((h << 4) | l);
os.width (2);
- os << "0x" << hex << v;
+ os << "0x" << hex << v << dec;
}
os.fill (prev_fill);
@@ -856,15 +874,15 @@ namespace CXX
// Date/time.
//
- Void InitValue::
+ void InitValue::
traverse (SemanticGraph::Fundamental::Date& t)
{
// date := [-]CCYY[N]*-MM-DD[Z|(+|-)HH:MM]
//
collapse (value_);
- Size b (0);
- Size e (value_.find ('-', value_[0] == '-' ? 5 : 4));
+ size_t b (0);
+ size_t e (value_.find ('-', value_[0] == '-' ? 5 : 4));
String year (value_, 0, e);
b = e + 1;
@@ -882,15 +900,15 @@ namespace CXX
os << ")";
}
- Void InitValue::
+ void InitValue::
traverse (SemanticGraph::Fundamental::DateTime& t)
{
// date_time := [-]CCYY[N]*-MM-DDTHH:MM:SS[.S+][Z|(+|-)HH:MM]
//
collapse (value_);
- Size b (0);
- Size e (value_.find ('-', value_[0] == '-' ? 5 : 4));
+ size_t b (0);
+ size_t e (value_.find ('-', value_[0] == '-' ? 5 : 4));
String year (value_, 0, e);
b = e + 1;
@@ -909,7 +927,7 @@ namespace CXX
e = b + 2;
for (; e < value_.size (); ++e)
{
- WideChar c (value_[e]);
+ wchar_t c (value_[e]);
if (c == 'Z' || c == '+' || c == '-')
break;
@@ -934,12 +952,12 @@ namespace CXX
namespace
{
- Size
- find_delim (String const& s, Size pos)
+ size_t
+ find_delim (String const& s, size_t pos)
{
for (; pos < s.size (); ++pos)
{
- WideChar c (s[pos]);
+ wchar_t c (s[pos]);
if (c == 'Y' || c == 'D' || c == 'M' || c == 'H' ||
c == 'M' || c == 'S' || c == 'T')
@@ -950,14 +968,14 @@ namespace CXX
}
}
- Void InitValue::
+ void InitValue::
traverse (SemanticGraph::Fundamental::Duration& t)
{
// duration := [-]P[nY][nM][nD][TnHnMn[.n+]S]
//
collapse (value_);
- Size b (1), e, n (value_.size ());
+ size_t b (1), e, n (value_.size ());
os << fq_name (t) << " (";
@@ -1053,7 +1071,7 @@ namespace CXX
os << ")";
}
- Void InitValue::
+ void InitValue::
traverse (SemanticGraph::Fundamental::Day& t)
{
// gday := ---DD[Z|(+|-)HH:MM]
@@ -1068,7 +1086,7 @@ namespace CXX
os << ")";
}
- Void InitValue::
+ void InitValue::
traverse (SemanticGraph::Fundamental::Month& t)
{
// gmonth := --MM[Z|(+|-)HH:MM]
@@ -1083,7 +1101,7 @@ namespace CXX
os << ")";
}
- Void InitValue::
+ void InitValue::
traverse (SemanticGraph::Fundamental::MonthDay& t)
{
// gmonth_day := --MM-DD[Z|(+|-)HH:MM]
@@ -1101,17 +1119,17 @@ namespace CXX
os << ")";
}
- Void InitValue::
+ void InitValue::
traverse (SemanticGraph::Fundamental::Year& t)
{
// gyear := [-]CCYY[N]*[Z|(+|-)HH:MM]
//
collapse (value_);
- Size pos (value_[0] == '-' ? 5 : 4);
+ size_t pos (value_[0] == '-' ? 5 : 4);
for (; pos < value_.size (); ++pos)
{
- WideChar c (value_[pos]);
+ wchar_t c (value_[pos]);
if (c == 'Z' || c == '+' || c == '-')
break;
@@ -1125,14 +1143,14 @@ namespace CXX
os << ")";
}
- Void InitValue::
+ void InitValue::
traverse (SemanticGraph::Fundamental::YearMonth& t)
{
// gyear_month := [-]CCYY[N]*-MM[Z|(+|-)HH:MM]
//
collapse (value_);
- Size pos (value_.find ('-', value_[0] == '-' ? 5 : 4));
+ size_t pos (value_.find ('-', value_[0] == '-' ? 5 : 4));
String year (value_, 0, pos);
String month (value_, pos + 1, 2);
@@ -1145,7 +1163,7 @@ namespace CXX
os << ")";
}
- Void InitValue::
+ void InitValue::
traverse (SemanticGraph::Fundamental::Time& t)
{
// time := HH:MM:SS[.S+][Z|(+|-)HH:MM]
@@ -1155,10 +1173,10 @@ namespace CXX
String hours (value_, 0, 2);
String minutes (value_, 3, 2);
- Size e (8);
+ size_t e (8);
for (; e < value_.size (); ++e)
{
- WideChar c (value_[e]);
+ wchar_t c (value_[e]);
if (c == 'Z' || c == '+' || c == '-')
break;
@@ -1176,8 +1194,8 @@ namespace CXX
os << ")";
}
- Void InitValue::
- time_zone (Size pos)
+ void InitValue::
+ time_zone (size_t pos)
{
// time_zone := Z|(+|-)HH:MM
//
@@ -1211,14 +1229,14 @@ namespace CXX
// Entity.
//
- Void InitValue::
+ void InitValue::
traverse (SemanticGraph::Fundamental::Entity&)
{
collapse (value_);
os << strlit (value_);
}
- Void InitValue::
+ void InitValue::
traverse (SemanticGraph::Fundamental::Entities&)
{
string_sequence_type (
@@ -1226,7 +1244,7 @@ namespace CXX
xs_ns ().find ("ENTITY").first->named ()));
}
- Void InitValue::
+ void InitValue::
string_sequence_type (SemanticGraph::Type& t)
{
collapse (value_);
@@ -1234,9 +1252,9 @@ namespace CXX
if (!value_)
return;
- Size b (0);
+ size_t b (0);
- for (Size e (value_.find (' ')); ; e = value_.find (' ', b))
+ for (size_t e (value_.find (' ')); ; e = value_.find (' ', b))
{
String v (value_, b, e != String::npos ? e - b : e);
diff --git a/xsd/xsd/cxx/tree/default-value.hxx b/xsd/xsd/cxx/tree/default-value.hxx
index c80132e..eb91a8c 100644
--- a/xsd/xsd/cxx/tree/default-value.hxx
+++ b/xsd/xsd/cxx/tree/default-value.hxx
@@ -1,6 +1,5 @@
// file : xsd/cxx/tree/default-value.hxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#ifndef CXX_TREE_DEFAULT_VALUE_HXX
@@ -17,9 +16,9 @@ namespace CXX
{
struct IsLiteralValue: IsFundamentalType, Traversal::Complex
{
- IsLiteralValue (Boolean& r);
+ IsLiteralValue (bool& r);
- virtual Void
+ virtual void
traverse (SemanticGraph::Complex&);
private:
@@ -57,64 +56,64 @@ namespace CXX
// Handle inheritance.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Complex&);
// Boolean.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Boolean&);
// Integral types.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Byte&);
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::UnsignedByte&);
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Short&);
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::UnsignedShort&);
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Int&);
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::UnsignedInt&);
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Long&);
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::UnsignedLong&);
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Integer&);
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NonPositiveInteger&);
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NonNegativeInteger&);
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::PositiveInteger&);
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NegativeInteger&);
// Floats.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Float&);
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Double&);
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Decimal&);
private:
@@ -148,25 +147,25 @@ namespace CXX
//
InitKind (Kind& r);
- virtual Void
+ virtual void
traverse (SemanticGraph::List&);
- virtual Void
+ virtual void
traverse (SemanticGraph::Complex&);
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Base64Binary&);
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::HexBinary&);
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NameTokens&);
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::IdRefs&);
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Entities&);
private:
@@ -178,6 +177,7 @@ namespace CXX
Traversal::Union,
Traversal::Complex,
+ Traversal::AnyType,
Traversal::AnySimpleType,
Traversal::Fundamental::String,
@@ -217,133 +217,136 @@ namespace CXX
{
InitValue (Context&);
- Void
+ void
data (String const& data)
{
data_ = data;
dispatch_count_ = 0;
}
- Void
+ void
dispatch (SemanticGraph::Node& type, String const& value);
- virtual Void
+ virtual void
traverse (SemanticGraph::List&);
- virtual Void
+ virtual void
traverse (SemanticGraph::Union&);
- virtual Void
+ virtual void
traverse (SemanticGraph::Complex&);
- // anySimpleType.
+ // anyType & anySimpleType.
//
- virtual Void
+ virtual void
+ traverse (SemanticGraph::AnyType&);
+
+ virtual void
traverse (SemanticGraph::AnySimpleType&);
// Strings.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::String&);
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NormalizedString&);
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Token&);
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NameToken&);
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NameTokens&);
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Name&);
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NCName&);
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Language&);
// Qualified name.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::QName&);
// ID/IDREF.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Id&);
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::IdRef&);
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::IdRefs&);
// URI.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::AnyURI&);
// Binary.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Base64Binary&);
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::HexBinary&);
// Date/time.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Date&);
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::DateTime&);
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Duration&);
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Day&);
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Month&);
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::MonthDay&);
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Year&);
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::YearMonth&);
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Time&);
// Entity.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Entity&);
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Entities&);
private:
- Void
+ void
string_sequence_type (SemanticGraph::Type& element_type);
- Void
- time_zone (Size pos);
+ void
+ time_zone (size_t pos);
private:
String value_;
String data_;
- Size dispatch_count_;
+ size_t dispatch_count_;
MemberTypeName type_name_;
LiteralValue literal_value_;
};
diff --git a/xsd/xsd/cxx/tree/elements.cxx b/xsd/xsd/cxx/tree/elements.cxx
index cad5a33..202ab62 100644
--- a/xsd/xsd/cxx/tree/elements.cxx
+++ b/xsd/xsd/cxx/tree/elements.cxx
@@ -1,6 +1,5 @@
// file : xsd/cxx/tree/elements.cxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#include <cxx/tree/elements.hxx>
@@ -11,55 +10,18 @@ namespace CXX
{
// Context
//
- Void Context::
- update_ns_scope () // Keeping this function first helps HP-UX
- { // (long symbols).
- ns_scope.clear ();
-
- Boolean first (true);
-
- for (NamespaceStack::Iterator i (ns_scope_stack.begin ());
- i != ns_scope_stack.end ();
- ++i)
- {
- // We only qualify names until the namespace level.
- //
- if (first)
- first = false;
- else
- ns_scope += L"::";
-
- ns_scope += *i;
- }
- }
-
Context::
Context (std::wostream& o,
SemanticGraph::Schema& root,
SemanticGraph::Path const& path,
- CLI::Options const& ops,
+ options_type const& ops,
Counts const& counts_,
- Boolean generate_xml_schema__,
+ bool generate_xml_schema__,
StringLiteralMap const* map,
Regex const* fe,
Regex const* he,
Regex const* ie)
- : CXX::Context (o,
- root,
- path,
- map,
- ops.value<CLI::char_type> (),
- ops.value<CLI::char_encoding> (),
- ops.value<CLI::include_with_brackets> (),
- ops.value<CLI::include_prefix> (),
- ops.value<CLI::export_symbol> (),
- ops.value<CLI::namespace_map> (),
- ops.value<CLI::namespace_regex> (),
- ops.value<CLI::namespace_regex_trace> (),
- ops.value<CLI::include_regex> (),
- ops.value<CLI::include_regex_trace> (),
- ops.value<CLI::generate_inline> (),
- ops.value<CLI::reserved_name> ()),
+ : CXX::Context (o, root, path, ops, map),
options (ops),
counts (counts_),
any_type (any_type_),
@@ -84,9 +46,10 @@ namespace CXX
as_decimal_type (as_decimal_type_),
generate_xml_schema (generate_xml_schema_),
doxygen (doxygen_),
- polymorphic (ops.value<CLI::generate_polymorphic> ()),
- polymorphic_all (ops.value<CLI::polymorphic_type_all> ()),
- detach (ops.value<CLI::generate_detach> ()),
+ polymorphic (ops.generate_polymorphic ()),
+ polymorphic_all (ops.polymorphic_type_all ()),
+ poly_plate (ops.polymorphic_plate ()),
+ detach (ops.generate_detach ()),
fwd_expr (fe),
hxx_expr (he),
ixx_expr (ie),
@@ -96,7 +59,7 @@ namespace CXX
qname_type_ (L"::xsd::cxx::xml::qualified_name< " + char_type + L" >"),
parser_type_ (L"::xsd::cxx::xml::dom::parser< " + char_type + L" >"),
generate_xml_schema_ (generate_xml_schema__),
- doxygen_ (ops.value<CLI::generate_doxygen> ()),
+ doxygen_ (ops.generate_doxygen ()),
ns_scope_stack (ns_scope_stack_),
cxx_uq_id_expr_ (L"^[a-zA-Z_]\\w*$"),
cxx_uq_id_expr (cxx_uq_id_expr_)
@@ -118,23 +81,25 @@ namespace CXX
container = xs_name + L"::" + xsc.get<String> ("container");
flags_type = xs_name + L"::" + xsc.get<String> ("flags");
- if (ops.value<CLI::generate_element_type> ())
+ if (ops.generate_element_type ())
element_type = xs_name + L"::" + xsc.get<String> ("element-type");
properties_type = xs_name + L"::" + xsc.get<String> ("properties");
- if (!ops.value<CLI::suppress_parsing> () ||
- ops.value<CLI::generate_serialization> ())
+ if (!ops.suppress_parsing () || ops.generate_serialization ())
{
error_handler_type = xs_name + L"::" +
xsc.get<String> ("error-handler");
}
- dom_auto_ptr_ = xs_name + L"::dom::auto_ptr";
+ dom_auto_ptr_ = xs_name + (std >= cxx_version::cxx11
+ ? L"::dom::unique_ptr"
+ : L"::dom::auto_ptr");
+
dom_node_key_ = xs_name + L"::dom::" +
xsc.get<String> ("tree-node-key");
- if (ops.value<CLI::generate_serialization> ())
+ if (ops.generate_serialization ())
{
as_double_type_ = xs_name + L"::" +
xsc.get<String> ("as-double");
@@ -152,17 +117,17 @@ namespace CXX
// istream and ostream are templates and for now use the same
// names regardless of the naming convention.
//
- if (!ops.value<CLI::generate_extraction> ().empty ())
+ if (!ops.generate_extraction ().empty ())
istream_type = xs_name + L"::istream";
- if (!ops.value<CLI::generate_insertion> ().empty ())
+ if (!ops.generate_insertion ().empty ())
ostream_type = xs_name + L"::ostream";
}
// Xerces-C++ namespace. IntelliSense for some reason does not like
// it fully-qualified (maybe because it's a namespace alias).
//
- if (ops.value<CLI::generate_intellisense> ())
+ if (ops.generate_intellisense ())
xerces_ns = "xercesc";
else
xerces_ns = "::xercesc";
@@ -178,14 +143,14 @@ namespace CXX
// Custom type mapping.
//
- typedef Containers::Vector<NarrowString> Vector;
// Direct custom type mapping.
//
{
- Vector const& v (ops.value<CLI::custom_type> ());
+ NarrowStrings const& v (ops.custom_type ());
- for (Vector::ConstIterator i (v.begin ()), e (v.end ()); i != e; ++i)
+ for (NarrowStrings::const_iterator i (v.begin ()),
+ e (v.end ()); i != e; ++i)
{
String s (*i);
@@ -194,7 +159,7 @@ namespace CXX
// Split the string in two parts at the last '='.
//
- Size pos (s.rfind ('='));
+ size_t pos (s.rfind ('='));
// If no delimiter found then both type and base are empty.
//
@@ -237,20 +202,21 @@ namespace CXX
// Regex custom type mapping.
//
{
- Vector const& v (ops.value<CLI::custom_type_regex> ());
+ NarrowStrings const& v (ops.custom_type_regex ());
- for (Vector::ConstIterator i (v.begin ()), e (v.end ()); i != e; ++i)
+ for (NarrowStrings::const_iterator i (v.begin ()),
+ e (v.end ()); i != e; ++i)
{
String s (*i);
if (s.empty ())
throw InvalidCustomTypeMapping (s, "mapping string is empty");
- WideChar delimiter (s[0]);
+ wchar_t delimiter (s[0]);
// First get pattern.
//
- Size pos (s.find (delimiter, 1));
+ size_t pos (s.find (delimiter, 1));
if (pos == String::npos)
throw InvalidCustomTypeMapping (
@@ -291,7 +257,7 @@ namespace CXX
}
regex_custom_type_map.push_back (
- RegexCustomTypeMapInfo (pat, type, base));
+ RegexCustomTypeMapInfo (WideRegexPat (pat), type, base));
}
}
}
@@ -325,6 +291,7 @@ namespace CXX
doxygen (c.doxygen),
polymorphic (c.polymorphic),
polymorphic_all (c.polymorphic_all),
+ poly_plate (c.poly_plate),
detach (c.detach),
fwd_expr (c.fwd_expr),
hxx_expr (c.hxx_expr),
@@ -366,6 +333,7 @@ namespace CXX
doxygen (c.doxygen),
polymorphic (c.polymorphic),
polymorphic_all (c.polymorphic_all),
+ poly_plate (c.poly_plate),
detach (c.detach),
fwd_expr (c.fwd_expr),
hxx_expr (c.hxx_expr),
@@ -378,7 +346,29 @@ namespace CXX
{
}
- Boolean Context::
+ void Context::
+ update_ns_scope ()
+ {
+ ns_scope.clear ();
+
+ bool first (true);
+
+ for (NamespaceStack::iterator i (ns_scope_stack.begin ());
+ i != ns_scope_stack.end ();
+ ++i)
+ {
+ // We only qualify names until the namespace level.
+ //
+ if (first)
+ first = false;
+ else
+ ns_scope += L"::";
+
+ ns_scope += *i;
+ }
+ }
+
+ bool Context::
custom_type (SemanticGraph::Type const& t, String& r) const
{
String const& name (t.name ());
@@ -386,7 +376,7 @@ namespace CXX
// First search the direct mapping.
//
{
- DirectCustomTypeMap::ConstIterator i (
+ DirectCustomTypeMap::const_iterator i (
direct_custom_type_map.find (name));
if (i != direct_custom_type_map.end ())
@@ -399,7 +389,7 @@ namespace CXX
// Second search the regex mapping.
//
- for (RegexCustomTypeMap::ConstIterator
+ for (RegexCustomTypeMap::const_iterator
i (regex_custom_type_map.begin ()),
e (regex_custom_type_map.end ());
i != e; ++i)
@@ -414,7 +404,7 @@ namespace CXX
return true;
}
- r = i->pat.merge (i->type_sub, name);
+ r = i->pat.replace (name, i->type_sub);
return true;
}
}
@@ -437,7 +427,7 @@ namespace CXX
return r;
}
- Boolean Context::
+ bool Context::
renamed_type (SemanticGraph::Type const& t, String& r) const
{
String const& name (t.name ());
@@ -445,7 +435,7 @@ namespace CXX
// First search the direct mapping.
//
{
- DirectCustomTypeMap::ConstIterator i (
+ DirectCustomTypeMap::const_iterator i (
direct_custom_type_map.find (name));
if (i != direct_custom_type_map.end ())
@@ -458,7 +448,7 @@ namespace CXX
// Second search the regex mapping.
//
- for (RegexCustomTypeMap::ConstIterator
+ for (RegexCustomTypeMap::const_iterator
i (regex_custom_type_map.begin ()),
e (regex_custom_type_map.end ());
i != e; ++i)
@@ -467,7 +457,7 @@ namespace CXX
{
if (!i->base_sub.empty ())
{
- r = i->pat.merge (i->base_sub, name);
+ r = i->pat.replace (name, i->base_sub);
}
else
r.clear ();
@@ -479,17 +469,17 @@ namespace CXX
return false;
}
- Void Context::
+ void Context::
write_annotation (SemanticGraph::Annotation& a)
{
String const& doc (a.documentation ());
- WideChar const* s (doc.c_str ());
- Size size (doc.size ());
+ wchar_t const* s (doc.c_str ());
+ size_t size (doc.size ());
// Remove leading and trailing whitespaces.
//
- while (*s == WideChar (0x20) || *s == WideChar (0x0A) ||
- *s == WideChar (0x0D) || *s == WideChar (0x09))
+ while (*s == wchar_t (0x20) || *s == wchar_t (0x0A) ||
+ *s == wchar_t (0x0D) || *s == wchar_t (0x09))
{
s++;
size--;
@@ -497,11 +487,11 @@ namespace CXX
if (size != 0)
{
- WideChar const* e (s + size - 1);
+ wchar_t const* e (s + size - 1);
while (e > s &&
- (*e == WideChar (0x20) || *e == WideChar (0x0A) ||
- *e == WideChar (0x0D) || *e == WideChar (0x09)))
+ (*e == wchar_t (0x20) || *e == wchar_t (0x0A) ||
+ *e == wchar_t (0x0D) || *e == wchar_t (0x09)))
--e;
size = s <= e ? e - s + 1 : 0;
@@ -514,15 +504,15 @@ namespace CXX
// Go over the data, forcing newline after 80 chars and adding
// ' * ' after each new line.
//
- WideChar const* last_space (0);
- WideChar const* b (s);
- WideChar const* e (s);
- Boolean after_newline (false);
- Boolean rogue (false);
+ wchar_t const* last_space (0);
+ wchar_t const* b (s);
+ wchar_t const* e (s);
+ bool after_newline (false);
+ bool rogue (false);
for (; e < s + size; ++e)
{
- UnsignedLong u (unicode_char (e)); // May advance e.
+ unsigned int u (unicode_char (e)); // May advance e.
// We are going to treat \v and \f as rogue here even though
// they can be present in C++ source code.
@@ -579,16 +569,16 @@ namespace CXX
}
}
- Void Context::
- write_rogue_text (WideChar const* s, Size size, Boolean rogue)
+ void Context::
+ write_rogue_text (wchar_t const* s, size_t size, bool rogue)
{
if (!rogue)
os.write (s, size);
else
{
- for (WideChar const* p (s); p < s + size; ++p)
+ for (wchar_t const* p (s); p < s + size; ++p)
{
- UnsignedLong u (unicode_char (p)); // May advance p.
+ unsigned int u (unicode_char (p)); // May advance p.
// We are going to treat \v and \f as rogue here even though
// they can be present in C++ source code.
@@ -596,36 +586,69 @@ namespace CXX
if (u > 127 || (u < 32 && u != '\t' && u != '\n'))
os.put ('?');
else
- os.put (static_cast<WideChar> (u));
+ os.put (static_cast<wchar_t> (u));
}
}
}
- Boolean Context::
+ bool Context::
polymorphic_p (SemanticGraph::Type& t)
{
+ // IDREF templates cannot be polymorphic.
+ //
+ if (!t.named_p () &&
+ (t.is_a<SemanticGraph::Fundamental::IdRef> () ||
+ t.is_a<SemanticGraph::Fundamental::IdRefs> ()))
+ return false;
+
if (polymorphic_all)
{
- Boolean fund (false);
+ bool fund (false);
IsFundamentalType test (fund);
test.dispatch (t);
return !fund;
}
else
- return t.context ().get<Boolean> ("polymorphic");
+ return t.context ().get<bool> ("polymorphic");
+ }
+
+ bool Context::
+ anonymous_substitutes_p (SemanticGraph::Type& t)
+ {
+ // IDREF templates cannot match.
+ //
+ if (!t.named_p () &&
+ (t.is_a<SemanticGraph::Fundamental::IdRef> () ||
+ t.is_a<SemanticGraph::Fundamental::IdRefs> ()))
+ return false;
+
+ // See which elements this type classifies.
+ //
+ for (SemanticGraph::Type::ClassifiesIterator i (t.classifies_begin ()),
+ e (t.classifies_end ()); i != e; ++i)
+ {
+ if (SemanticGraph::Element* e =
+ dynamic_cast<SemanticGraph::Element*> (&i->instance ()))
+ {
+ if (e->substitutes_p ())
+ return true;
+ }
+ }
+
+ return false;
}
// GenerateDefautCtor
//
GenerateDefaultCtor::
- GenerateDefaultCtor (Context& c, Boolean& generate, Boolean no_base)
+ GenerateDefaultCtor (Context& c, bool& generate, bool no_base)
: Context (c), generate_ (generate), no_base_ (no_base)
{
*this >> inherits_ >> *this;
*this >> names_ >> *this;
}
- Void GenerateDefaultCtor::
+ void GenerateDefaultCtor::
traverse (SemanticGraph::Complex& c)
{
// Make sure we figure out if we have any required members before
@@ -637,38 +660,38 @@ namespace CXX
Complex::inherits (c, inherits_);
}
- Void GenerateDefaultCtor::
+ void GenerateDefaultCtor::
traverse (SemanticGraph::Type&)
{
if (!no_base_)
generate_ = true;
}
- Void GenerateDefaultCtor::
+ void GenerateDefaultCtor::
traverse (SemanticGraph::Enumeration&)
{
if (!no_base_)
generate_ = true;
}
- Void GenerateDefaultCtor::
+ void GenerateDefaultCtor::
traverse (SemanticGraph::Element& e)
{
if (!skip (e) && min (e) == 1 && max (e) == 1)
generate_ = true;
}
- Void GenerateDefaultCtor::
+ void GenerateDefaultCtor::
traverse (SemanticGraph::Attribute& a)
{
if (min (a) == 1 && !a.fixed_p ())
generate_ = true;
}
- Void GenerateDefaultCtor::
+ void GenerateDefaultCtor::
traverse (SemanticGraph::Any& a)
{
- if (options.value<CLI::generate_wildcard> () &&
+ if (options.generate_wildcard () &&
min (a) == 1 && max (a) == 1)
generate_ = true;
}
@@ -677,7 +700,7 @@ namespace CXX
// GenerateFromBaseCtor
//
GenerateFromBaseCtor::
- GenerateFromBaseCtor (Context& c, Boolean& generate)
+ GenerateFromBaseCtor (Context& c, bool& generate)
: generate_ (generate),
custom_ (false),
traverser_ (c, generate, custom_)
@@ -685,7 +708,7 @@ namespace CXX
inherits_ >> traverser_;
}
- Void GenerateFromBaseCtor::
+ void GenerateFromBaseCtor::
traverse (SemanticGraph::Complex& c)
{
inherits (c, inherits_);
@@ -703,14 +726,14 @@ namespace CXX
}
GenerateFromBaseCtor::Traverser::
- Traverser (Context& c, Boolean& generate, Boolean& custom)
+ Traverser (Context& c, bool& generate, bool& custom)
: Context (c), generate_ (generate), custom_ (custom)
{
*this >> inherits_ >> *this;
*this >> names_ >> *this;
}
- Void GenerateFromBaseCtor::Traverser::
+ void GenerateFromBaseCtor::Traverser::
traverse (SemanticGraph::Type& t)
{
if (!custom_)
@@ -720,7 +743,7 @@ namespace CXX
}
}
- Void GenerateFromBaseCtor::Traverser::
+ void GenerateFromBaseCtor::Traverser::
traverse (SemanticGraph::Complex& c)
{
names (c, names_);
@@ -732,24 +755,24 @@ namespace CXX
traverse (static_cast<SemanticGraph::Type&> (c));
}
- Void GenerateFromBaseCtor::Traverser::
+ void GenerateFromBaseCtor::Traverser::
traverse (SemanticGraph::Element& e)
{
if (!skip (e) && min (e) == 1 && max (e) == 1)
generate_ = true;
}
- Void GenerateFromBaseCtor::Traverser::
+ void GenerateFromBaseCtor::Traverser::
traverse (SemanticGraph::Attribute& a)
{
if (min (a) == 1 && !a.fixed_p ())
generate_ = true;
}
- Void GenerateFromBaseCtor::Traverser::
+ void GenerateFromBaseCtor::Traverser::
traverse (SemanticGraph::Any& a)
{
- if (options.value<CLI::generate_wildcard> () &&
+ if (options.generate_wildcard () &&
min (a) == 1 && max (a) == 1)
generate_ = true;
}
@@ -758,10 +781,10 @@ namespace CXX
//
HasComplexPolyNonOptArgs::
HasComplexPolyNonOptArgs (Context& c,
- Boolean base,
- Boolean& complex,
- Boolean& poly,
- Boolean& clash)
+ bool base,
+ bool& complex,
+ bool& poly,
+ bool& clash)
: Context (c),
complex_ (complex),
poly_ (poly),
@@ -773,7 +796,7 @@ namespace CXX
*this >> names_ >> *this;
}
- Void HasComplexPolyNonOptArgs::
+ void HasComplexPolyNonOptArgs::
traverse (SemanticGraph::Complex& c)
{
// No optimizations: need to check every arg for clashes.
@@ -782,14 +805,14 @@ namespace CXX
names (c, names_);
}
- Void HasComplexPolyNonOptArgs::
+ void HasComplexPolyNonOptArgs::
traverse (SemanticGraph::Element& e)
{
if (!skip (e) && min (e) == 1 && max (e) == 1)
{
- Boolean poly (polymorphic && polymorphic_p (e.type ()));
+ bool poly (polymorphic && polymorphic_p (e.type ()));
- Boolean simple (true);
+ bool simple (true);
IsSimpleType t (simple);
t.dispatch (e.type ());
@@ -807,15 +830,15 @@ namespace CXX
// FromBaseCtorArg
//
FromBaseCtorArg::
- FromBaseCtorArg (Context& c, ArgType at, Boolean arg)
+ FromBaseCtorArg (Context& c, CtorArgType at, bool arg)
: Context (c), arg_type_ (at), arg_ (arg)
{
}
- Void FromBaseCtorArg::
+ void FromBaseCtorArg::
traverse (SemanticGraph::Any& a)
{
- if (!options.value<CLI::generate_wildcard> ())
+ if (!options.generate_wildcard ())
return;
if (min (a) == 1 && max (a) == 1)
@@ -830,7 +853,7 @@ namespace CXX
}
}
- Void FromBaseCtorArg::
+ void FromBaseCtorArg::
traverse (SemanticGraph::Element& e)
{
if (skip (e))
@@ -842,29 +865,29 @@ namespace CXX
os << "," << endl;
- Boolean auto_ptr (false);
+ bool ptr (false);
switch (arg_type_)
{
- case arg_complex_auto_ptr:
+ case CtorArgType::complex_auto_ptr:
{
- Boolean simple (true);
+ bool simple (true);
IsSimpleType t (simple);
t.dispatch (e.type ());
- auto_ptr = !simple;
+ ptr = !simple;
break;
}
- case arg_poly_auto_ptr:
+ case CtorArgType::poly_auto_ptr:
{
- auto_ptr = polymorphic && polymorphic_p (e.type ());
+ ptr = polymorphic && polymorphic_p (e.type ());
break;
}
- case arg_type:
+ case CtorArgType::type:
break;
}
- if (auto_ptr)
- os << "::std::auto_ptr< " << etype (e) << " >&";
+ if (ptr)
+ os << auto_ptr << "< " << etype (e) << " >";
else
os << "const " << etype (e) << "&";
@@ -873,7 +896,7 @@ namespace CXX
}
}
- Void FromBaseCtorArg::
+ void FromBaseCtorArg::
traverse (SemanticGraph::Attribute& a)
{
// Note that we are not going to include attributes with
@@ -895,7 +918,7 @@ namespace CXX
// CtorArgs
//
CtorArgs::
- CtorArgs (Context& c, ArgType at)
+ CtorArgs (Context& c, CtorArgType at)
: Context (c),
arg_type_ (at),
base_arg_ (0),
@@ -907,7 +930,7 @@ namespace CXX
}
CtorArgs::
- CtorArgs (Context& c, ArgType at, String& base_arg)
+ CtorArgs (Context& c, CtorArgType at, String& base_arg)
: Context (c),
arg_type_ (at),
base_arg_ (&base_arg),
@@ -918,7 +941,7 @@ namespace CXX
*this >> names_ >> *this;
}
- Void CtorArgs::
+ void CtorArgs::
traverse (SemanticGraph::Type& t)
{
os << comma () << "const ";
@@ -929,13 +952,17 @@ namespace CXX
if (base_arg_ != 0)
{
- *base_arg_ = L"_xsd_" + ename (t) + L"_base";
+ // IDREF templates don't have a name.
+ //
+ *base_arg_ = t.named_p ()
+ ? (L"_xsd_" + ename (t) + L"_base")
+ : L"_xsd_base";
os << " " << *base_arg_;
}
}
- Void CtorArgs::
+ void CtorArgs::
traverse (SemanticGraph::Enumeration& e)
{
os << comma () << "const ";
@@ -952,10 +979,10 @@ namespace CXX
}
}
- Void CtorArgs::
+ void CtorArgs::
traverse (SemanticGraph::Any& a)
{
- if (!options.value<CLI::generate_wildcard> ())
+ if (!options.generate_wildcard ())
return;
if (min (a) == 1 && max (a) == 1)
@@ -967,7 +994,7 @@ namespace CXX
}
}
- Void CtorArgs::
+ void CtorArgs::
traverse (SemanticGraph::Element& e)
{
if (skip (e))
@@ -975,29 +1002,29 @@ namespace CXX
if (min (e) == 1 && max (e) == 1)
{
- Boolean auto_ptr (false);
+ bool ptr (false);
switch (arg_type_)
{
- case arg_complex_auto_ptr:
+ case CtorArgType::complex_auto_ptr:
{
- Boolean simple (true);
+ bool simple (true);
IsSimpleType t (simple);
t.dispatch (e.type ());
- auto_ptr = !simple;
+ ptr = !simple;
break;
}
- case arg_poly_auto_ptr:
+ case CtorArgType::poly_auto_ptr:
{
- auto_ptr = polymorphic && polymorphic_p (e.type ());
+ ptr = polymorphic && polymorphic_p (e.type ());
break;
}
- case arg_type:
+ case CtorArgType::type:
break;
}
- if (auto_ptr)
- os << comma () << "::std::auto_ptr< " << etype (e) << " >&";
+ if (ptr)
+ os << comma () << auto_ptr << "< " << etype (e) << " >";
else
os << comma () << "const " << etype (e) << "&";
@@ -1006,7 +1033,7 @@ namespace CXX
}
}
- Void CtorArgs::
+ void CtorArgs::
traverse (SemanticGraph::Attribute& a)
{
// Note that we are not going to include attributes with
@@ -1025,7 +1052,7 @@ namespace CXX
String CtorArgs::
comma ()
{
- Boolean tmp (first_);
+ bool tmp (first_);
first_ = false;
return tmp ? "" : ",\n";
}
@@ -1034,17 +1061,17 @@ namespace CXX
// CtorArgsWithoutBase
//
CtorArgsWithoutBase::
- CtorArgsWithoutBase (Context& c, ArgType at, Boolean arg, Boolean first)
+ CtorArgsWithoutBase (Context& c, CtorArgType at, bool arg, bool first)
: Context (c), arg_type_ (at), arg_ (arg), first_ (first)
{
*this >> inherits_ >> *this;
*this >> names_ >> *this;
}
- Void CtorArgsWithoutBase::
+ void CtorArgsWithoutBase::
traverse (SemanticGraph::Any& a)
{
- if (!options.value<CLI::generate_wildcard> ())
+ if (!options.generate_wildcard ())
return;
if (min (a) == 1 && max (a) == 1)
@@ -1056,7 +1083,7 @@ namespace CXX
}
}
- Void CtorArgsWithoutBase::
+ void CtorArgsWithoutBase::
traverse (SemanticGraph::Element& e)
{
if (skip (e))
@@ -1064,29 +1091,29 @@ namespace CXX
if (min (e) == 1 && max (e) == 1)
{
- Boolean auto_ptr (false);
+ bool ptr (false);
switch (arg_type_)
{
- case arg_complex_auto_ptr:
+ case CtorArgType::complex_auto_ptr:
{
- Boolean simple (true);
+ bool simple (true);
IsSimpleType t (simple);
t.dispatch (e.type ());
- auto_ptr = !simple;
+ ptr = !simple;
break;
}
- case arg_poly_auto_ptr:
+ case CtorArgType::poly_auto_ptr:
{
- auto_ptr = polymorphic && polymorphic_p (e.type ());
+ ptr = polymorphic && polymorphic_p (e.type ());
break;
}
- case arg_type:
+ case CtorArgType::type:
break;
}
- if (auto_ptr)
- os << comma () << "::std::auto_ptr< " << etype (e) << " >&";
+ if (ptr)
+ os << comma () << auto_ptr << "< " << etype (e) << " >";
else
os << comma () << "const " << etype (e) << "&";
@@ -1095,7 +1122,7 @@ namespace CXX
}
}
- Void CtorArgsWithoutBase::
+ void CtorArgsWithoutBase::
traverse (SemanticGraph::Attribute& a)
{
// Note that we are not going to include attributes with
@@ -1114,14 +1141,14 @@ namespace CXX
String CtorArgsWithoutBase::
comma ()
{
- Boolean tmp (first_);
+ bool tmp (first_);
first_ = false;
return tmp ? "" : ",\n";
}
// GlobalElementBase
//
- Boolean GlobalElementBase::
+ bool GlobalElementBase::
generate_p (SemanticGraph::Element& e)
{
if (e.substitutes_p () && ctx_.polymorphic)
@@ -1133,44 +1160,44 @@ namespace CXX
// If we are not generating element types nor parsing/serialization
// code then we won't generate anything from it.
//
- if (!ctx_.options.value<CLI::generate_element_type> () &&
- ctx_.options.value<CLI::suppress_parsing> () &&
- !ctx_.options.value<CLI::generate_serialization> ())
+ if (!ctx_.options.generate_element_type () &&
+ ctx_.options.suppress_parsing () &&
+ !ctx_.options.generate_serialization ())
return false;
return true;
}
- Boolean GlobalElementBase::
+ bool GlobalElementBase::
doc_root_p (SemanticGraph::Element& e)
{
- if (!ctx_.options.value<CLI::root_element_first> () &&
- !ctx_.options.value<CLI::root_element_last> () &&
- !ctx_.options.value<CLI::root_element_all> () &&
- !ctx_.options.value<CLI::root_element_none> () &&
- ctx_.options.value<CLI::root_element> ().empty ())
+ if (!ctx_.options.root_element_first () &&
+ !ctx_.options.root_element_last () &&
+ !ctx_.options.root_element_all () &&
+ !ctx_.options.root_element_none () &&
+ ctx_.options.root_element ().empty ())
return true; // By default treat them all.
- if (ctx_.options.value<CLI::root_element_none> ())
+ if (ctx_.options.root_element_none ())
return false;
- if (ctx_.options.value<CLI::root_element_all> ())
+ if (ctx_.options.root_element_all ())
return true;
- if (ctx_.options.value<CLI::root_element_first> () &&
+ if (ctx_.options.root_element_first () &&
e.context ().count ("first") != 0)
return true;
- if (ctx_.options.value<CLI::root_element_last> () &&
+ if (ctx_.options.root_element_last () &&
e.context ().count ("last") != 0)
return true;
- typedef Cult::Containers::Vector<NarrowString> Names;
- Names const& names (ctx_.options.value<CLI::root_element> ());
+ NarrowStrings const& names (ctx_.options.root_element ());
// Hopefully nobody will specify more than a handful of names ;-).
//
- for (Names::ConstIterator i (names.begin ()); i != names.end (); ++i)
+ for (NarrowStrings::const_iterator i (names.begin ());
+ i != names.end (); ++i)
{
String name (*i);
@@ -1185,8 +1212,8 @@ namespace CXX
//
Namespace::
Namespace (Context& c,
- UnsignedLong first,
- UnsignedLong last)
+ size_t first,
+ size_t last)
: CXX::Namespace (c, *this),
GlobalElementBase (c),
ctx_ (c),
@@ -1196,7 +1223,7 @@ namespace CXX
{
}
- Void Namespace::
+ void Namespace::
traverse (Type& ns)
{
using SemanticGraph::Element;
@@ -1205,7 +1232,7 @@ namespace CXX
CXX::Namespace::traverse (ns);
else
{
- Boolean opened (false);
+ bool opened (false);
for (Type::NamesIterator i (ns.names_begin ());
i != ns.names_end (); ++i)
@@ -1235,13 +1262,13 @@ namespace CXX
}
}
- Void Namespace::
- enter (Type&, String const& name, Boolean)
+ void Namespace::
+ enter (Type&, String const& name, bool)
{
ctx_.enter_ns_scope (name);
}
- Void Namespace::
+ void Namespace::
leave ()
{
ctx_.leave_ns_scope ();
@@ -1249,7 +1276,7 @@ namespace CXX
// Includes
//
- Void TypeForward::
+ void TypeForward::
traverse (SemanticGraph::Type& t)
{
String const& name (ename (t));
@@ -1271,14 +1298,14 @@ namespace CXX
os << "class " << name << ";";
}
- Void Includes::
+ void Includes::
traverse_ (SemanticGraph::Uses& u)
{
// Support for weak (forward) inclusion used in the file-per-type
// compilation model.
//
Type t (type_);
- Boolean weak (u.context ().count ("weak"));
+ bool weak (u.context ().count ("weak"));
SemanticGraph::Schema& s (u.schema ());
if (weak && t == header)
@@ -1301,6 +1328,7 @@ namespace CXX
s.context ().count ("renamed")
? s.context ().get<SemanticGraph::Path> ("renamed")
: u.path ());
+ path.normalize ();
// Try to use the portable representation of the path. If that
// fails, fall back to the native representation.
@@ -1308,15 +1336,11 @@ namespace CXX
NarrowString path_str;
try
{
- path_str = path.string ();
+ path_str = path.posix_string ();
}
catch (SemanticGraph::InvalidPath const&)
{
-#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2
- path_str = path.native_file_string ();
-#else
path_str = path.string ();
-#endif
}
String inc_path;
@@ -1325,25 +1349,25 @@ namespace CXX
{
case forward:
{
- inc_path = ctx_.fwd_expr->merge (path_str);
+ inc_path = ctx_.fwd_expr->replace (path_str);
break;
}
case header:
case source:
{
- inc_path = ctx_.hxx_expr->merge (path_str);
+ inc_path = ctx_.hxx_expr->replace (path_str);
break;
}
case inline_:
{
if (weak)
{
- inc_path = ctx_.hxx_expr->merge (path_str);
+ inc_path = ctx_.hxx_expr->replace (path_str);
ctx_.os << "#include " << ctx_.process_include_path (inc_path)
<< endl;
}
- inc_path = ctx_.ixx_expr->merge (path_str);
+ inc_path = ctx_.ixx_expr->replace (path_str);
break;
}
}
diff --git a/xsd/xsd/cxx/tree/elements.hxx b/xsd/xsd/cxx/tree/elements.hxx
index afe3951..6874e6a 100644
--- a/xsd/xsd/cxx/tree/elements.hxx
+++ b/xsd/xsd/cxx/tree/elements.hxx
@@ -1,23 +1,23 @@
// file : xsd/cxx/tree/elements.hxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#ifndef CXX_TREE_ELEMENTS_HXX
#define CXX_TREE_ELEMENTS_HXX
+#include <map>
+#include <set>
+#include <deque>
+#include <vector>
#include <sstream>
-#include <cult/containers/map.hxx>
-#include <cult/containers/deque.hxx>
-#include <cult/containers/vector.hxx>
+#include <cutl/re.hxx>
-#include <backend-elements/regex.hxx>
+#include <types.hxx>
#include <cxx/elements.hxx>
-#include <cxx/tree/cli.hxx>
-
+#include <cxx/tree/options.hxx>
namespace CXX
{
@@ -33,15 +33,15 @@ namespace CXX
{
}
- UnsignedLong global_types;
- UnsignedLong global_elements;
- UnsignedLong generated_global_elements;
+ size_t global_types;
+ size_t global_elements;
+ size_t generated_global_elements;
// Complexity value for each global type and generated global
// element, in order.
//
- Cult::Containers::Vector<UnsignedLong> complexity;
- UnsignedLong complexity_total;
+ std::vector<size_t> complexity;
+ size_t complexity_total;
};
struct InvalidCustomTypeMapping
@@ -69,13 +69,63 @@ namespace CXX
String reason_;
};
+ // A set of potentially qualified XML Schema type names.
+ //
+ struct TypeNameSet
+ {
+ template <typename I>
+ TypeNameSet (I begin, I end)
+ {
+ for (; begin != end; ++begin)
+ insert (*begin);
+ }
+
+ void
+ insert (String const& name)
+ {
+ size_t p (name.rfind ('#'));
+
+ if (p == String::npos)
+ unames_.insert (name);
+ else
+ qnames_.insert (name);
+ }
+
+ bool
+ find (SemanticGraph::Type& t)
+ {
+ if (!unames_.empty ())
+ {
+ if (unames_.find (t.name ()) != unames_.end ())
+ return true;
+ }
+
+ if (!qnames_.empty ())
+ {
+ if (qnames_.find (t.scope ().name () + L"#" + t.name ()) !=
+ qnames_.end ())
+ return true;
+ }
+
+ return false;
+ }
+
+ private:
+ typedef std::set<String> StringSet;
+
+ StringSet unames_;
+ StringSet qnames_;
+ };
+
//
//
class Context: public CXX::Context
{
public:
- typedef BackendElements::Regex::Expression<Char> Regex;
- typedef BackendElements::Regex::Pattern<WideChar> WideRegexPat;
+ typedef cutl::re::regexsub Regex;
+ typedef cutl::re::wregex WideRegexPat;
+
+ typedef Tree::options options_type;
struct DirectCustomTypeMapInfo
{
@@ -103,21 +153,16 @@ namespace CXX
String base_sub;
};
- typedef
- Cult::Containers::Vector<RegexCustomTypeMapInfo>
- RegexCustomTypeMap;
-
- typedef
- Cult::Containers::Map<String, DirectCustomTypeMapInfo>
- DirectCustomTypeMap;
+ typedef std::vector<RegexCustomTypeMapInfo> RegexCustomTypeMap;
+ typedef std::map<String, DirectCustomTypeMapInfo> DirectCustomTypeMap;
public:
Context (std::wostream& o,
SemanticGraph::Schema& root,
SemanticGraph::Path const& path,
- CLI::Options const& ops,
+ options_type const& ops,
Counts const& counts_,
- Boolean generate_xml_schema,
+ bool generate_xml_schema,
StringLiteralMap const*,
Regex const* fwd_expr,
Regex const* hxx_expr,
@@ -139,7 +184,7 @@ namespace CXX
// populated with the custom type name or empty if the
// original name should be used.
//
- Boolean
+ bool
custom_type (SemanticGraph::Type const&, String& name) const;
// Returns true if this type has been renamed as part of the
@@ -147,7 +192,7 @@ namespace CXX
// name string is populated with the new name or empty if
// the type should not be generated at all.
//
- Boolean
+ bool
renamed_type (SemanticGraph::Type const&, String& name) const;
public:
@@ -155,21 +200,43 @@ namespace CXX
// line after 80 characters as well as "commentizing" the text by
// adding '* ' after each newline.
//
- Void
+ void
write_annotation (SemanticGraph::Annotation&);
//
//
public:
- Boolean
+ static bool
+ ordered_p (SemanticGraph::Type const& t)
+ {
+ return t.context ().count ("ordered") &&
+ t.context ().get<bool> ("ordered");
+ }
+
+ // Check if we are generating mixed support for this type. We only
+ // do it for ordered types.
+ //
+ static bool
+ mixed_p (SemanticGraph::Complex const& c)
+ {
+ return c.mixed_p () && ordered_p (c);
+ }
+
+ bool
polymorphic_p (SemanticGraph::Type&);
- Boolean
+ bool
anonymous_p (SemanticGraph::Type const& t)
{
return t.context ().count ("anonymous");
}
+ // Return true if this anonymous type is defined in an element
+ // that belongs to a substitution group.
+ //
+ bool
+ anonymous_substitutes_p (SemanticGraph::Type&);
+
// Escaped names.
//
public:
@@ -329,7 +396,7 @@ namespace CXX
// dom_document
//
- static Boolean
+ static bool
edom_document_p (SemanticGraph::Complex const& c)
{
return c.context ().count ("dom-document");
@@ -341,7 +408,7 @@ namespace CXX
return c.context ().get<String> ("dom-document");
}
- static Boolean
+ static bool
edom_document_member_p (SemanticGraph::Complex const& c)
{
return c.context ().count ("dom-document-member");
@@ -368,14 +435,14 @@ namespace CXX
}
public:
- Void
+ void
enter_ns_scope (String const& name)
{
ns_scope_stack.push_back (name);
update_ns_scope ();
}
- Void
+ void
leave_ns_scope ()
{
ns_scope_stack.pop_back ();
@@ -383,18 +450,18 @@ namespace CXX
}
private:
- Void
+ void
update_ns_scope ();
private:
// Write text that may contain characters that we will have
// to escape (indicated by the rogue flag).
//
- Void
- write_rogue_text (WideChar const* s, Size size, Boolean rogue);
+ void
+ write_rogue_text (wchar_t const* s, size_t size, bool rogue);
public:
- CLI::Options const& options;
+ options_type const& options;
Counts const& counts;
String& any_type;
String& any_simple_type;
@@ -417,11 +484,12 @@ namespace CXX
String& as_double_type;
String& as_decimal_type;
- Boolean& generate_xml_schema;
- Boolean& doxygen;
- Boolean polymorphic;
- Boolean polymorphic_all;
- Boolean detach;
+ bool& generate_xml_schema;
+ bool& doxygen;
+ bool polymorphic;
+ bool polymorphic_all;
+ unsigned long poly_plate;
+ bool detach;
Regex const* fwd_expr;
Regex const* hxx_expr;
@@ -454,16 +522,11 @@ namespace CXX
String as_double_type_;
String as_decimal_type_;
- Boolean generate_xml_schema_;
- Boolean doxygen_;
+ bool generate_xml_schema_;
+ bool doxygen_;
- typedef
- Cult::Containers::Deque<String>
- NamespaceStack;
-
- typedef
- Cult::Containers::Deque<String>
- ScopeStack;
+ typedef std::deque<String> NamespaceStack;
+ typedef std::deque<String> ScopeStack;
String ns_scope_;
@@ -501,86 +564,86 @@ namespace CXX
Traversal::Fundamental::Decimal
{
- IsFundamentalType (Boolean& r)
+ IsFundamentalType (bool& r)
: r_ (r)
{
}
// Integral types.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Byte&)
{
r_ = true;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::UnsignedByte&)
{
r_ = true;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Short&)
{
r_ = true;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::UnsignedShort&)
{
r_ = true;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Int&)
{
r_ = true;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::UnsignedInt&)
{
r_ = true;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Long&)
{
r_ = true;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::UnsignedLong&)
{
r_ = true;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Integer&)
{
r_ = true;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NonPositiveInteger&)
{
r_ = true;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NonNegativeInteger&)
{
r_ = true;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::PositiveInteger&)
{
r_ = true;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NegativeInteger&)
{
r_ = true;
@@ -588,7 +651,7 @@ namespace CXX
// Boolean.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Boolean&)
{
r_ = true;
@@ -596,26 +659,26 @@ namespace CXX
// Floats.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Float&)
{
r_ = true;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Double&)
{
r_ = true;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Decimal&)
{
r_ = true;
}
private:
- Boolean& r_;
+ bool& r_;
};
// Check whether this is a string-based type.
@@ -630,19 +693,19 @@ namespace CXX
Traversal::Fundamental::NCName,
Traversal::Fundamental::Language
{
- IsStringBasedType (Boolean& r)
+ IsStringBasedType (bool& r)
: r_ (r)
{
*this >> inherits_ >> *this;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Complex& c)
{
inherits (c, inherits_);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Union&)
{
// Current mapping of union is string-based.
@@ -652,50 +715,50 @@ namespace CXX
// Strings.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::String&)
{
r_ = true;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NormalizedString&)
{
r_ = true;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Token&)
{
r_ = true;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NameToken&)
{
r_ = true;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Name&)
{
r_ = true;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NCName&)
{
r_ = true;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Language&)
{
r_ = true;
}
private:
- Boolean& r_;
+ bool& r_;
Traversal::Inherits inherits_;
};
@@ -713,7 +776,7 @@ namespace CXX
inherits_ >> enum_;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Complex& c)
{
inherits (c, inherits_);
@@ -727,7 +790,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& e)
{
if (e_ == 0)
@@ -820,25 +883,25 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Type&)
{
abort ();
}
- virtual Void
+ virtual void
traverse (SemanticGraph::List& l)
{
os << fq_name (l);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Union& u)
{
os << fq_name (u);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Complex& c)
{
os << fq_name (c);
@@ -846,13 +909,13 @@ namespace CXX
// anyType & anySimpleType.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::AnyType& t)
{
os << fq_name (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::AnySimpleType& t)
{
os << fq_name (t);
@@ -860,79 +923,79 @@ namespace CXX
// Integral types.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Byte& t)
{
os << fq_name (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::UnsignedByte& t)
{
os << fq_name (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Short& t)
{
os << fq_name (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::UnsignedShort& t)
{
os << fq_name (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Int& t)
{
os << fq_name (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::UnsignedInt& t)
{
os << fq_name (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Long& t)
{
os << fq_name (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::UnsignedLong& t)
{
os << fq_name (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Integer& t)
{
os << fq_name (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NonPositiveInteger& t)
{
os << fq_name (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NonNegativeInteger& t)
{
os << fq_name (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::PositiveInteger& t)
{
os << fq_name (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NegativeInteger& t)
{
os << fq_name (t);
@@ -940,7 +1003,7 @@ namespace CXX
// Boolean.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Boolean& t)
{
os << fq_name (t);
@@ -948,19 +1011,19 @@ namespace CXX
// Floats.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Float& t)
{
os << fq_name (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Double& t)
{
os << fq_name (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Decimal& t)
{
os << fq_name (t);
@@ -968,49 +1031,49 @@ namespace CXX
// Strings.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::String& t)
{
os << fq_name (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NormalizedString& t)
{
os << fq_name (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Token& t)
{
os << fq_name (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NameToken& t)
{
os << fq_name (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NameTokens& t)
{
os << fq_name (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Name& t)
{
os << fq_name (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NCName& t)
{
os << fq_name (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Language& t)
{
os << fq_name (t);
@@ -1019,7 +1082,7 @@ namespace CXX
// Qualified name.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::QName& t)
{
os << fq_name (t);
@@ -1028,13 +1091,13 @@ namespace CXX
// ID/IDREF.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Id& t)
{
os << fq_name (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::IdRef& t)
{
if (t.named_p ())
@@ -1054,7 +1117,7 @@ namespace CXX
}
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::IdRefs& t)
{
if (t.named_p ())
@@ -1077,7 +1140,7 @@ namespace CXX
// URI.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::AnyURI& t)
{
os << fq_name (t);
@@ -1085,13 +1148,13 @@ namespace CXX
// Binary.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Base64Binary& t)
{
os << fq_name (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::HexBinary& t)
{
os << fq_name (t);
@@ -1100,55 +1163,55 @@ namespace CXX
// Date/time.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Date& t)
{
os << fq_name (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::DateTime& t)
{
os << fq_name (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Duration& t)
{
os << fq_name (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Day& t)
{
os << fq_name (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Month& t)
{
os << fq_name (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::MonthDay& t)
{
os << fq_name (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Year& t)
{
os << fq_name (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::YearMonth& t)
{
os << fq_name (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Time& t)
{
os << fq_name (t);
@@ -1156,13 +1219,13 @@ namespace CXX
// Entity.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Entity& t)
{
os << fq_name (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Entities& t)
{
os << fq_name (t);
@@ -1200,7 +1263,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
fundamental_base (SemanticGraph::Type& t)
{
os << "::xsd::cxx::tree::fundamental_base< " <<
@@ -1210,79 +1273,79 @@ namespace CXX
// Integrals.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Byte& t)
{
fundamental_base (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::UnsignedByte& t)
{
fundamental_base (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Short& t)
{
fundamental_base (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::UnsignedShort& t)
{
fundamental_base (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Int& t)
{
fundamental_base (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::UnsignedInt& t)
{
fundamental_base (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Long& t)
{
fundamental_base (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::UnsignedLong& t)
{
fundamental_base (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Integer& t)
{
fundamental_base (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NonPositiveInteger& t)
{
fundamental_base (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NonNegativeInteger& t)
{
fundamental_base (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::PositiveInteger& t)
{
fundamental_base (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NegativeInteger& t)
{
fundamental_base (t);
@@ -1290,7 +1353,7 @@ namespace CXX
// Boolean.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Boolean& t)
{
fundamental_base (t);
@@ -1298,13 +1361,13 @@ namespace CXX
// Floats.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Float& t)
{
fundamental_base (t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Double& t)
{
os << "::xsd::cxx::tree::fundamental_base< " <<
@@ -1313,7 +1376,7 @@ namespace CXX
"::xsd::cxx::tree::schema_type::double_ >";
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Decimal& t)
{
os << "::xsd::cxx::tree::fundamental_base< " <<
@@ -1330,42 +1393,46 @@ namespace CXX
Traversal::Any,
Traversal::AnyAttribute
{
- IsSimpleType (Boolean& v)
+ IsSimpleType (bool& v)
: v_ (v)
{
*this >> names_ >> *this;
*this >> inherits_ >> *this;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Complex& c)
{
- names (c, names_);
+ if (c.mixed_p ())
+ v_ = false;
+
+ if (v_)
+ names (c, names_);
if (v_)
inherits (c, inherits_);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Member&)
{
v_ = false;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Any&)
{
v_ = false;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::AnyAttribute&)
{
v_ = false;
}
private:
- Boolean& v_;
+ bool& v_;
Traversal::Names names_;
Traversal::Inherits inherits_;
};
@@ -1383,29 +1450,29 @@ namespace CXX
{
// generate should initially be false.
//
- GenerateDefaultCtor (Context&, Boolean& generate, Boolean no_base);
+ GenerateDefaultCtor (Context&, bool& generate, bool no_base);
- virtual Void
+ virtual void
traverse (SemanticGraph::Complex&);
- virtual Void
+ virtual void
traverse (SemanticGraph::Type&);
- virtual Void
+ virtual void
traverse (SemanticGraph::Enumeration&);
- virtual Void
+ virtual void
traverse (SemanticGraph::Element&);
- virtual Void
+ virtual void
traverse (SemanticGraph::Attribute&);
- virtual Void
+ virtual void
traverse (SemanticGraph::Any&);
private:
- Boolean& generate_;
- Boolean no_base_;
+ bool& generate_;
+ bool no_base_;
private:
Traversal::Inherits inherits_;
@@ -1418,14 +1485,14 @@ namespace CXX
{
// generate should initially be false.
//
- GenerateFromBaseCtor (Context& c, Boolean& generate);
+ GenerateFromBaseCtor (Context& c, bool& generate);
- virtual Void
+ virtual void
traverse (SemanticGraph::Complex& c);
private:
- Boolean& generate_;
- Boolean custom_;
+ bool& generate_;
+ bool custom_;
// Note that we are not interested in anyAttribute since it is always
// mapped to a sequence.
@@ -1437,26 +1504,26 @@ namespace CXX
Traversal::Any,
Context
{
- Traverser (Context& c, Boolean& generate, Boolean& custom);
+ Traverser (Context& c, bool& generate, bool& custom);
- virtual Void
+ virtual void
traverse (SemanticGraph::Type&);
- virtual Void
+ virtual void
traverse (SemanticGraph::Complex&);
- virtual Void
+ virtual void
traverse (SemanticGraph::Attribute&);
- virtual Void
+ virtual void
traverse (SemanticGraph::Element&);
- virtual Void
+ virtual void
traverse (SemanticGraph::Any&);
private:
- Boolean& generate_;
- Boolean& custom_;
+ bool& generate_;
+ bool& custom_;
private:
Traversal::Inherits inherits_;
@@ -1477,26 +1544,44 @@ namespace CXX
// should initially be true.
//
HasComplexPolyNonOptArgs (Context& c,
- Boolean including_base,
- Boolean& complex,
- Boolean& poly,
- Boolean& clash);
+ bool including_base,
+ bool& complex,
+ bool& poly,
+ bool& clash);
- virtual Void
+ virtual void
traverse (SemanticGraph::Complex&);
- virtual Void
+ virtual void
traverse (SemanticGraph::Element&);
private:
- Boolean& complex_;
- Boolean& poly_;
- Boolean& clash_;
+ bool& complex_;
+ bool& poly_;
+ bool& clash_;
Traversal::Inherits inherits_;
Traversal::Names names_;
};
+ // Contructor argument types.
+ //
+ struct CtorArgType
+ {
+ enum Value
+ {
+ type,
+ complex_auto_ptr,
+ poly_auto_ptr
+ };
+
+ CtorArgType (Value v = Value (0)) : v_ (v) {}
+ operator Value () const {return v_;}
+
+ private:
+ Value v_;
+ };
+
// Immediate non-optional member. Note that AnyAttribute is always
// mapped to a sequence.
//
@@ -1505,27 +1590,20 @@ namespace CXX
Traversal::Attribute,
Context
{
- enum ArgType
- {
- arg_type,
- arg_complex_auto_ptr,
- arg_poly_auto_ptr
- };
+ FromBaseCtorArg (Context& c, CtorArgType, bool arg);
- FromBaseCtorArg (Context& c, ArgType, Boolean arg);
-
- virtual Void
+ virtual void
traverse (SemanticGraph::Any&);
- virtual Void
+ virtual void
traverse (SemanticGraph::Attribute&);
- virtual Void
+ virtual void
traverse (SemanticGraph::Element&);
private:
- ArgType arg_type_;
- Boolean arg_;
+ CtorArgType arg_type_;
+ bool arg_;
};
// List of all non-optional members and a simple base. Note that
@@ -1539,32 +1617,25 @@ namespace CXX
Traversal::Attribute,
Context
{
- enum ArgType
- {
- arg_type,
- arg_complex_auto_ptr,
- arg_poly_auto_ptr
- };
-
// The second version outputs the argument name and stores
// in in the base_arg string.
//
- CtorArgs (Context&, ArgType);
- CtorArgs (Context&, ArgType, String& base_arg);
+ CtorArgs (Context&, CtorArgType);
+ CtorArgs (Context&, CtorArgType, String& base_arg);
- virtual Void
+ virtual void
traverse (SemanticGraph::Type&);
- virtual Void
+ virtual void
traverse (SemanticGraph::Enumeration&);
- virtual Void
+ virtual void
traverse (SemanticGraph::Any&);
- virtual Void
+ virtual void
traverse (SemanticGraph::Attribute&);
- virtual Void
+ virtual void
traverse (SemanticGraph::Element&);
private:
@@ -1572,10 +1643,10 @@ namespace CXX
comma ();
private:
- ArgType arg_type_;
+ CtorArgType arg_type_;
String base_;
String* base_arg_;
- Boolean first_;
+ bool first_;
private:
Traversal::Inherits inherits_;
@@ -1607,92 +1678,92 @@ namespace CXX
{
// generate should initially be false.
//
- GenerateWithoutBaseCtor (Boolean& generate)
+ GenerateWithoutBaseCtor (bool& generate)
: generate_ (generate)
{
*this >> inherits_ >> *this;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::List&)
{
generate_ = true;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Union&)
{
// No default initialization.
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Complex& c)
{
Complex::inherits (c);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Enumeration&)
{
// No default initialization.
}
- virtual Void
+ virtual void
traverse (SemanticGraph::AnyType&)
{
generate_ = true;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::AnySimpleType&)
{
generate_ = true;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::String&)
{
generate_ = true;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NormalizedString&)
{
generate_ = true;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Token&)
{
generate_ = true;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NameTokens&)
{
generate_ = true;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::IdRefs&)
{
generate_ = true;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Base64Binary&)
{
generate_ = true;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::HexBinary&)
{
generate_ = true;
}
private:
- Boolean& generate_;
+ bool& generate_;
Traversal::Inherits inherits_;
};
@@ -1706,22 +1777,15 @@ namespace CXX
Traversal::Attribute,
Context
{
- enum ArgType
- {
- arg_type,
- arg_complex_auto_ptr,
- arg_poly_auto_ptr
- };
-
- CtorArgsWithoutBase (Context& c, ArgType, Boolean arg, Boolean first);
+ CtorArgsWithoutBase (Context& c, CtorArgType, bool arg, bool first);
- virtual Void
+ virtual void
traverse (SemanticGraph::Any&);
- virtual Void
+ virtual void
traverse (SemanticGraph::Element&);
- virtual Void
+ virtual void
traverse (SemanticGraph::Attribute&);
private:
@@ -1729,9 +1793,9 @@ namespace CXX
comma ();
private:
- ArgType arg_type_;
- Boolean arg_;
- Boolean first_;
+ CtorArgType arg_type_;
+ bool arg_;
+ bool first_;
private:
Traversal::Inherits inherits_;
@@ -1747,10 +1811,10 @@ namespace CXX
{
}
- Boolean
+ bool
generate_p (SemanticGraph::Element&);
- Boolean
+ bool
doc_root_p (SemanticGraph::Element&);
private:
@@ -1765,26 +1829,26 @@ namespace CXX
CXX::Namespace::ScopeTracker
{
Namespace (Context&,
- UnsignedLong first = 1,
- UnsignedLong last = 0);
+ size_t first = 1,
+ size_t last = 0);
- virtual Void
+ virtual void
traverse (Type&);
protected:
- virtual Void
- enter (Type&, String const& name, Boolean last);
+ virtual void
+ enter (Type&, String const& name, bool last);
- virtual Void
+ virtual void
leave ();
protected:
Context& ctx_;
private:
- UnsignedLong first_;
- UnsignedLong last_;
- UnsignedLong count_;
+ size_t first_;
+ size_t last_;
+ size_t count_;
};
//
@@ -1796,8 +1860,8 @@ namespace CXX
{
}
- virtual Void
- enter (Type& ns, String const& name, Boolean last)
+ virtual void
+ enter (Type& ns, String const& name, bool last)
{
Namespace::enter (ns, name, last);
@@ -1823,7 +1887,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Type& t);
};
@@ -1841,33 +1905,33 @@ namespace CXX
Includes (Context& c, Type type)
: ctx_ (c),
type_ (type),
- forward_ (c.options.value<CLI::generate_forward> ()),
+ forward_ (c.options.generate_forward ()),
namespace_ (c),
type_forward_ (c)
{
schema_ >> schema_names_ >> namespace_ >> names_ >> type_forward_;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Imports& i)
{
traverse_ (i);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Includes& i)
{
traverse_ (i);
}
private:
- Void
+ void
traverse_ (SemanticGraph::Uses&);
private:
Context& ctx_;
Type type_;
- Boolean forward_;
+ bool forward_;
Traversal::Schema schema_;
Traversal::Names schema_names_;
@@ -1907,85 +1971,85 @@ namespace CXX
// Integral types.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Byte& t)
{
gen_include (t, "byte.hxx");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::UnsignedByte& t)
{
gen_include (t, "unsigned-byte.hxx");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Short& t)
{
gen_include (t, "short.hxx");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::UnsignedShort& t)
{
gen_include (t, "unsigned-short.hxx");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Int& t)
{
gen_include (t, "int.hxx");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::UnsignedInt& t)
{
gen_include (t, "unsigned-int.hxx");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Long& t)
{
if (!long_)
long_ = gen_include (t, "long.hxx");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::UnsignedLong& t)
{
if (!unsigned_long_)
unsigned_long_ = gen_include (t, "unsigned-long.hxx");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Integer& t)
{
if (!long_)
long_ = gen_include (t, "long.hxx");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NonPositiveInteger& t)
{
if (!long_)
long_ = gen_include (t, "long.hxx");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NonNegativeInteger& t)
{
if (!unsigned_long_)
unsigned_long_ = gen_include (t, "unsigned-long.hxx");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::PositiveInteger& t)
{
if (!unsigned_long_)
unsigned_long_ = gen_include (t, "unsigned-long.hxx");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NegativeInteger& t)
{
if (!long_)
@@ -1994,7 +2058,7 @@ namespace CXX
// Boolean.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Boolean& t)
{
gen_include (t, "boolean.hxx");
@@ -2002,26 +2066,26 @@ namespace CXX
// Floats.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Float& t)
{
gen_include (t, "float.hxx");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Double& t)
{
gen_include (t, "double.hxx");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Decimal& t)
{
gen_include (t, "decimal.hxx");
}
private:
- Boolean
+ bool
gen_include (SemanticGraph::Type& t, String const& file)
{
String custom;
@@ -2046,8 +2110,8 @@ namespace CXX
private:
String prefix_;
- Boolean long_;
- Boolean unsigned_long_;
+ bool long_;
+ bool unsigned_long_;
};
}
}
diff --git a/xsd/xsd/cxx/tree/fundamental-header.hxx b/xsd/xsd/cxx/tree/fundamental-header.hxx
index 71cfbea..925d65e 100644
--- a/xsd/xsd/cxx/tree/fundamental-header.hxx
+++ b/xsd/xsd/cxx/tree/fundamental-header.hxx
@@ -1,13 +1,13 @@
// file : xsd/cxx/tree/fundamental-header.hxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#ifndef CXX_TREE_FUNDAMENTAL_HEADER_HXX
#define CXX_TREE_FUNDAMENTAL_HEADER_HXX
-#include <cult/containers/set.hxx>
-#include <cult/containers/vector.hxx>
+#include <set>
+#include <vector>
+#include <algorithm>
#include <xsd-frontend/semantic-graph.hxx>
#include <xsd-frontend/traversal.hxx>
@@ -80,7 +80,7 @@ namespace CXX
FundamentalNamespace (Context& c)
: DocumentedNamespace (c),
Context (c),
- export_ (c.options.value<CLI::export_xml_schema> () && type_exp)
+ export_ (c.options.export_xml_schema () && type_exp)
{
*this >> names_ >> *this;
@@ -88,13 +88,13 @@ namespace CXX
xs_ns_ = ns_name (xs_ns ());
}
- Void
+ void
gen_typedef (String const& name,
String const& type,
String const& arg1 = L"",
String const& arg2 = L"",
String const& arg3 = L"",
- Boolean export_type = true)
+ bool export_type = true)
{
os << "typedef " << type;
@@ -225,7 +225,7 @@ namespace CXX
// anyType and anySimpleType
//
- virtual Void
+ virtual void
traverse (SemanticGraph::AnyType& t)
{
os << "// anyType and anySimpleType." << endl
@@ -237,11 +237,11 @@ namespace CXX
type_ = built_in_type (t, "::xsd::cxx::tree::type");
}
- virtual Void
+ virtual void
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
@@ -259,7 +259,7 @@ namespace CXX
// Integrals.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Byte& t)
{
os << "// 8-bit" << endl
@@ -271,14 +271,14 @@ namespace CXX
built_in_type (t, "signed char");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::UnsignedByte& t)
{
built_in_type (t, "unsigned char");
os << endl;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Short& t)
{
os << "// 16-bit" << endl
@@ -290,14 +290,14 @@ namespace CXX
built_in_type (t, "short");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::UnsignedShort& t)
{
built_in_type (t, "unsigned short");
os << endl;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Int& t)
{
os << "// 32-bit" << endl
@@ -309,14 +309,14 @@ namespace CXX
built_in_type (t, "int");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::UnsignedInt& t)
{
built_in_type (t, "unsigned int");
os << endl;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Long& t)
{
os << "// 64-bit" << endl
@@ -328,14 +328,14 @@ namespace CXX
built_in_type (t, "long long");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::UnsignedLong& t)
{
built_in_type (t, "unsigned long long");
os << endl;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Integer& t)
{
os << "// Supposed to be arbitrary-length integral types." << endl
@@ -347,25 +347,25 @@ namespace CXX
built_in_type (t, "long long");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NonPositiveInteger& t)
{
built_in_type (t, "long long");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NonNegativeInteger& t)
{
built_in_type (t, "unsigned long long");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::PositiveInteger& t)
{
built_in_type (t, "unsigned long long");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NegativeInteger& t)
{
built_in_type (t, "long long");
@@ -374,7 +374,7 @@ namespace CXX
// Boolean.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Boolean& t)
{
os << "// Boolean." << endl
@@ -390,7 +390,7 @@ namespace CXX
// Floats.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Float& t)
{
os << "// Floating-point types." << endl
@@ -402,13 +402,13 @@ namespace CXX
built_in_type (t, "float");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Double& t)
{
double_ = built_in_type (t, "double");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Decimal& t)
{
decimal_ = built_in_type (t, "double");
@@ -418,7 +418,7 @@ namespace CXX
// Strings.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::String& t)
{
os << "// String types." << endl
@@ -431,7 +431,7 @@ namespace CXX
t, L"::xsd::cxx::tree::string< " + char_type + L", ", simple_type_);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NormalizedString& t)
{
norm_string_ = built_in_type (
@@ -440,21 +440,21 @@ namespace CXX
string_);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Token& t)
{
token_ = built_in_type (
t, L"::xsd::cxx::tree::token< " + char_type + L", ", norm_string_);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NameToken& t)
{
nmtoken_ = built_in_type (
t, L"::xsd::cxx::tree::nmtoken< " + char_type + L", ", token_);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NameTokens& t)
{
built_in_type (
@@ -464,21 +464,21 @@ namespace CXX
nmtoken_);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Name& t)
{
name_ = built_in_type (
t, L"::xsd::cxx::tree::name< " + char_type + L", ", token_);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NCName& t)
{
ncname_ = built_in_type (
t, L"::xsd::cxx::tree::ncname< " + char_type + L", ", name_);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Language& t)
{
built_in_type (
@@ -489,7 +489,7 @@ namespace CXX
// ID/IDREF.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Id& t)
{
os << "// ID/IDREF." << endl
@@ -502,14 +502,14 @@ namespace CXX
t, L"::xsd::cxx::tree::id< " + char_type + L", ", ncname_);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::IdRef& t)
{
idref_ = built_in_type (
t, L"::xsd::cxx::tree::idref< " + char_type + L", ", ncname_, type_);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::IdRefs& t)
{
built_in_type (
@@ -524,7 +524,7 @@ namespace CXX
// URI.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::AnyURI& t)
{
os << "// URI." << endl
@@ -541,7 +541,7 @@ namespace CXX
// Qualified name.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::QName& t)
{
os << "// Qualified name." << endl
@@ -562,7 +562,7 @@ namespace CXX
// Binary.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Base64Binary& t)
{
os << "// Binary." << endl
@@ -586,7 +586,7 @@ namespace CXX
simple_type_);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::HexBinary& t)
{
built_in_type (
@@ -600,7 +600,7 @@ namespace CXX
// Date/time.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Date& t)
{
os << "// Date/time." << endl
@@ -622,7 +622,7 @@ namespace CXX
t, L"::xsd::cxx::tree::date< " + char_type + L", ", simple_type_);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::DateTime& t)
{
built_in_type (
@@ -631,7 +631,7 @@ namespace CXX
simple_type_);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Duration& t)
{
built_in_type (
@@ -640,21 +640,21 @@ namespace CXX
simple_type_);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Day& t)
{
built_in_type (
t, L"::xsd::cxx::tree::gday< " + char_type + L", ", simple_type_);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Month& t)
{
built_in_type (
t, L"::xsd::cxx::tree::gmonth< " + char_type + L", ", simple_type_);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::MonthDay& t)
{
built_in_type (
@@ -663,14 +663,14 @@ namespace CXX
simple_type_);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Year& t)
{
built_in_type (
t, L"::xsd::cxx::tree::gyear< " + char_type + L", ", simple_type_);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::YearMonth& t)
{
built_in_type (
@@ -679,7 +679,7 @@ namespace CXX
simple_type_);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Time& t)
{
built_in_type (
@@ -690,7 +690,7 @@ namespace CXX
// Entity.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Entity& t)
{
os << "// Entity." << endl
@@ -703,7 +703,7 @@ namespace CXX
t, L"::xsd::cxx::tree::entity< " + char_type + L", ", ncname_);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Entities& t)
{
built_in_type (
@@ -715,16 +715,27 @@ namespace CXX
os << endl;
}
- virtual Void
+ virtual void
post (SemanticGraph::Namespace& n)
{
SemanticGraph::Context& c (xs_ns ().context());
- Boolean parsing (!options.value<CLI::suppress_parsing> ());
- Boolean serialization (options.value<CLI::generate_serialization> ());
- Boolean element_map (options.value<CLI::generate_element_map> ());
+ bool parsing (!options.suppress_parsing ());
+ bool serialization (options.generate_serialization ());
+ bool element_map (options.generate_element_map ());
- if (options.value<CLI::generate_element_type> ())
+ {
+ if (doxygen)
+ os << endl
+ << "/**" << endl
+ << " * @brief Content order sequence entry." << endl
+ << " */" << endl;
+
+ gen_typedef (c.get<String> ("content-order"),
+ "::xsd::cxx::tree::content_order");
+ }
+
+ if (options.generate_element_type ())
{
if (doxygen)
os << "/**" << endl
@@ -838,7 +849,7 @@ namespace CXX
//@@ Can't change names of ostream/istream since they are
// templates.
//
- if (!options.value<CLI::generate_insertion> ().empty ())
+ if (!options.generate_insertion ().empty ())
{
if (doxygen)
os << "/**" << endl
@@ -852,7 +863,7 @@ namespace CXX
<< endl;
}
- if (!options.value<CLI::generate_extraction> ().empty ())
+ if (!options.generate_extraction ().empty ())
{
if (doxygen)
os << "/**" << endl
@@ -1050,7 +1061,7 @@ namespace CXX
L"::xsd::cxx::tree::no_prefix_mapping< " + char_type + L" >");
}
- if (options.value<CLI::generate_polymorphic> ())
+ if (options.generate_polymorphic ())
{
if (parsing || serialization)
{
@@ -1145,7 +1156,8 @@ namespace CXX
<< "{";
// @@ Disregarding current naming convention by using the
- // fixed name (no template typedef).
+ // fixed name (even in C++11, template alias is not yet
+ // widely supported).
//
if (doxygen)
os << "/**" << endl
@@ -1155,8 +1167,12 @@ namespace CXX
os << "// Automatic pointer for DOMDocument." << endl
<< "//" << endl;
- os << "using ::xsd::cxx::xml::dom::auto_ptr;"
- << endl;
+ if (std >= cxx_version::cxx11)
+ os << "using ::xsd::cxx::xml::dom::unique_ptr;";
+ else
+ os << "using ::xsd::cxx::xml::dom::auto_ptr;";
+
+ os << endl;
if (parsing)
{
@@ -1228,7 +1244,7 @@ namespace CXX
{
StringSet ns_set;
- for (StringList::ConstIterator i (exports_.begin ());
+ for (StringList::const_iterator i (exports_.begin ());
i != exports_.end (); ++i)
{
String const& e (*i);
@@ -1245,14 +1261,14 @@ namespace CXX
<< "namespace cxx"
<< "{";
- for (StringSet::ConstIterator i (ns_set.begin ());
+ for (StringSet::const_iterator i (ns_set.begin ());
i != ns_set.end (); ++i)
{
String const& ns (*i);
String prefix (L"::xsd::cxx::" + ns);
- Size n (1);
- for (Size b (0), e (ns.find (':')); ; n++)
+ size_t n (1);
+ for (size_t b (0), e (ns.find (':')); ; n++)
{
os << "namespace " << String (ns, b, e)
<< "{";
@@ -1264,7 +1280,7 @@ namespace CXX
e = ns.find (':', b);
}
- for (StringList::ConstIterator i (exports_.begin ());
+ for (StringList::const_iterator i (exports_.begin ());
i != exports_.end (); ++i)
{
String const& e (*i);
@@ -1289,10 +1305,10 @@ namespace CXX
}
private:
- typedef Cult::Containers::Set<String> StringSet;
- typedef Cult::Containers::Vector<String> StringList;
+ typedef std::set<String> StringSet;
+ typedef std::vector<String> StringList;
- Boolean export_;
+ bool export_;
StringList exports_;
StringSet exports_set_;
String xs_ns_;
diff --git a/xsd/xsd/cxx/tree/generator.cxx b/xsd/xsd/cxx/tree/generator.cxx
index fe5286a..7a413bd 100644
--- a/xsd/xsd/cxx/tree/generator.cxx
+++ b/xsd/xsd/cxx/tree/generator.cxx
@@ -1,8 +1,22 @@
// file : xsd/cxx/tree/generator.cxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+#include <vector>
+#include <algorithm>
+#include <iostream>
+#include <fstream>
+
+#include <cutl/re.hxx>
+#include <cutl/shared-ptr.hxx>
+
+#include <cutl/compiler/code-stream.hxx>
+#include <cutl/compiler/cxx-indenter.hxx>
+#include <cutl/compiler/sloc-counter.hxx>
+
+#include <xsd-frontend/semantic-graph.hxx>
+#include <xsd-frontend/generators/dependencies.hxx>
+
#include <cxx/tree/generator.hxx>
#include <cxx/tree/elements.hxx>
@@ -10,6 +24,7 @@
#include <cxx/tree/counter.hxx>
#include <cxx/tree/validator.hxx>
#include <cxx/tree/name-processor.hxx>
+#include <cxx/tree/order-processor.hxx>
#include <cxx/tree/polymorphism-processor.hxx>
#include <cxx/tree/tree-forward.hxx>
@@ -30,45 +45,25 @@
#include <cxx/tree/stream-insertion-source.hxx>
#include <cxx/tree/stream-extraction-source.hxx>
-#include <xsd-frontend/semantic-graph.hxx>
-
-#include <backend-elements/regex.hxx>
-#include <backend-elements/indentation/cxx.hxx>
-#include <backend-elements/indentation/sloc.hxx>
-#include <backend-elements/indentation/clip.hxx>
-
-#include <cult/containers/set.hxx>
-#include <cult/containers/vector.hxx>
-
-#include <boost/filesystem/fstream.hpp>
-
-#include <iostream>
-
-#include <usage.hxx>
+#include <cxx/tree/options.hxx>
#include "../../../libxsd/xsd/cxx/version.hxx"
-using std::endl;
-using std::wcerr;
-
+using namespace std;
+using namespace cutl;
using namespace XSDFrontend::SemanticGraph;
//
//
-typedef
-boost::filesystem::wifstream
-WideInputFileStream;
-
-typedef
-boost::filesystem::wofstream
-WideOutputFileStream;
+typedef std::wifstream WideInputFileStream;
+typedef std::wofstream WideOutputFileStream;
namespace CXX
{
namespace
{
- Char const copyright_gpl[] =
- "// Copyright (C) 2005-2010 Code Synthesis Tools CC\n"
+ char const copyright_gpl[] =
+ "// Copyright (c) 2005-2014 Code Synthesis Tools CC\n"
"//\n"
"// This program was generated by CodeSynthesis XSD, an XML Schema to\n"
"// C++ data binding compiler.\n"
@@ -101,8 +96,8 @@ namespace CXX
"// in the accompanying FLOSSE file.\n"
"//\n\n";
- Char const copyright_proprietary[] =
- "// Copyright (C) 2005-2010 Code Synthesis Tools CC\n"
+ char const copyright_proprietary[] =
+ "// Copyright (c) 2005-2014 Code Synthesis Tools CC\n"
"//\n"
"// This program was generated by CodeSynthesis XSD, an XML Schema\n"
"// to C++ data binding compiler, in the Proprietary License mode.\n"
@@ -112,673 +107,23 @@ namespace CXX
"//\n\n";
}
- namespace Tree
- {
- namespace CLI
- {
- extern Key char_type = "char-type";
- extern Key char_encoding = "char-encoding";
- extern Key output_dir = "output-dir";
- extern Key generate_polymorphic = "generate-polymorphic";
- extern Key polymorphic_type = "polymorphic-type";
- extern Key polymorphic_type_all = "polymorphic-type-all";
- extern Key generate_serialization = "generate-serialization";
- extern Key generate_inline = "generate-inline";
- extern Key generate_ostream = "generate-ostream";
- extern Key generate_doxygen = "generate-doxygen";
- extern Key generate_comparison = "generate-comparison";
- extern Key generate_default_ctor = "generate-default-ctor";
- extern Key generate_from_base_ctor = "generate-from-base-ctor";
- extern Key generate_detach = "generate-detach";
- extern Key generate_wildcard = "generate-wildcard";
- extern Key generate_insertion = "generate-insertion";
- extern Key generate_extraction = "generate-extraction";
- extern Key generate_forward = "generate-forward";
- extern Key generate_xml_schema = "generate-xml-schema";
- extern Key extern_xml_schema = "extern-xml-schema";
- extern Key suppress_parsing = "suppress-parsing";
- extern Key generate_element_type = "generate-element-type";
- extern Key generate_element_map = "generate-element-map";
- extern Key generate_intellisense = "generate-intellisense";
- extern Key omit_default_attributes = "omit-default-attributes";
- extern Key namespace_map = "namespace-map";
- extern Key namespace_regex = "namespace-regex";
- extern Key namespace_regex_trace = "namespace-regex-trace";
- extern Key reserved_name = "reserved-name";
- extern Key type_naming = "type-naming";
- extern Key function_naming = "function-naming";
- extern Key type_regex = "type-regex";
- extern Key accessor_regex = "accessor-regex";
- extern Key one_accessor_regex = "one-accessor-regex";
- extern Key opt_accessor_regex = "opt-accessor-regex";
- extern Key seq_accessor_regex = "seq-accessor-regex";
- extern Key modifier_regex = "modifier-regex";
- extern Key one_modifier_regex = "one-modifier-regex";
- extern Key opt_modifier_regex = "opt-modifier-regex";
- extern Key seq_modifier_regex = "seq-modifier-regex";
- extern Key parser_regex = "parser-regex";
- extern Key serializer_regex = "serializer-regex";
- extern Key enumerator_regex = "enumerator-regex";
- extern Key element_type_regex = "element-type-regex";
- extern Key name_regex_trace = "name-regex-trace";
- extern Key include_with_brackets = "include-with-brackets";
- extern Key include_prefix = "include-prefix";
- extern Key include_regex = "include-regex";
- extern Key include_regex_trace = "include-regex-trace";
- extern Key guard_prefix = "guard-prefix";
- extern Key root_element_first = "root-element-first";
- extern Key root_element_last = "root-element-last";
- extern Key root_element_all = "root-element-all";
- extern Key root_element_none = "root-element-none";
- extern Key root_element = "root-element";
- extern Key custom_type = "custom-type";
- extern Key custom_type_regex = "custom-type-regex";
- extern Key hxx_suffix = "hxx-suffix";
- extern Key ixx_suffix = "ixx-suffix";
- extern Key cxx_suffix = "cxx-suffix";
- extern Key fwd_suffix = "fwd-suffix";
- extern Key hxx_regex = "hxx-regex";
- extern Key ixx_regex = "ixx-regex";
- extern Key cxx_regex = "cxx-regex";
- extern Key fwd_regex = "fwd-regex";
- extern Key hxx_prologue = "hxx-prologue";
- extern Key ixx_prologue = "ixx-prologue";
- extern Key cxx_prologue = "cxx-prologue";
- extern Key fwd_prologue = "fwd-prologue";
- extern Key prologue = "prologue";
- extern Key hxx_epilogue = "hxx-epilogue";
- extern Key ixx_epilogue = "ixx-epilogue";
- extern Key cxx_epilogue = "cxx-epilogue";
- extern Key fwd_epilogue = "fwd-epilogue";
- extern Key epilogue = "epilogue";
- extern Key hxx_prologue_file = "hxx-prologue-file";
- extern Key ixx_prologue_file = "ixx-prologue-file";
- extern Key cxx_prologue_file = "cxx-prologue-file";
- extern Key fwd_prologue_file = "fwd-prologue-file";
- extern Key prologue_file = "prologue-file";
- extern Key hxx_epilogue_file = "hxx-epilogue-file";
- extern Key ixx_epilogue_file = "ixx-epilogue-file";
- extern Key cxx_epilogue_file = "cxx-epilogue-file";
- extern Key fwd_epilogue_file = "fwd-epilogue-file";
- extern Key epilogue_file = "epilogue-file";
- extern Key parts = "parts";
- extern Key parts_suffix = "parts-suffix";
- extern Key export_symbol = "export-symbol";
- extern Key export_xml_schema = "export-xml-schema";
- extern Key export_maps = "export-maps";
- extern Key import_maps = "import-maps";
- extern Key show_anonymous = "show-anonymous";
- extern Key show_sloc = "show-sloc";
- extern Key proprietary_license = "proprietary-license";
- extern Key disable_multi_import = "disable-multi-import";
- }
- }
-
- Void Tree::Generator::
+ void Tree::Generator::
usage ()
{
- std::wostream& e (wcerr);
- ::CLI::Indent::Clip< ::CLI::OptionsUsage, WideChar> clip (e);
-
- e << "--char-type <type>" << endl
- << " Use <type> as the base character type. Valid\n"
- << " values are 'char' (default) and 'wchar_t'."
- << endl;
-
- e << "--char-encoding <enc>" << endl
- << " Specify the character encoding that should be used\n"
- << " in the object model. Valid values for the 'char'\n"
- << " character type are 'utf8' (default), 'iso8859-1',\n"
- << " 'lcp', and 'custom'. For the 'wchar_t' character\n"
- << " type the only valid value is 'auto'."
- << endl;
-
- e << "--output-dir <dir>" << endl
- << " Write generated files to <dir> instead of current\n"
- << " directory."
- << endl;
-
- e << "--generate-polymorphic" << endl
- << " Generate polymorphism-aware code. Specify this\n"
- << " option if you use substitution groups or xsi:type."
- << endl;
-
- e << "--polymorphic-type <type>" << endl
- << " Indicate that <type> is a root of a polymorphic\n"
- << " type hierarchy."
- << endl;
-
- e << "--polymorphic-type-all" << endl
- << " Indicate that all types should be treated as\n"
- << " polymorphic."
- << endl;
-
- e << "--generate-serialization" << endl
- << " Generate serialization functions. They convert an\n"
- << " in-memory representation back to XML."
- << endl;
-
- e << "--generate-inline" << endl
- << " Generate certain functions inline."
- << endl;
-
- e << "--generate-ostream" << endl
- << " Generate ostream insertion operators."
- << endl;
-
- e << "--generate-doxygen" << endl
- << " Generate documentation comments in the Doxygen\n"
- << " format."
- << endl;
-
- e << "--generate-comparison" << endl
- << " Generate comparison operators."
- << endl;
-
- e << "--generate-default-ctor" << endl
- << " Generate default constructors even for types that\n"
- << " have required members."
- << endl;
-
- e << "--generate-from-base-ctor" << endl
- << " Generate from-base constructors."
- << endl;
-
- e << "--generate-detach" << endl
- << " Generate detach functions for required members."
- << endl;
-
- e << "--generate-wildcard" << endl
- << " Generate accessors/modifiers as well as parsing\n"
- << " and serialization code for XML Schema wildcards."
- << endl;
-
- e << "--generate-insertion <os>" << endl
- << " Generate data representation stream insertion\n"
- << " operators for the <os> output stream type."
- << endl;
-
- e << "--generate-extraction <is>" << endl
- << " Generate data representation stream extraction\n"
- << " constructors for the <is> input stream type."
- << endl;
-
- e << "--generate-forward" << endl
- << " Generate forward declaration file."
- << endl;
-
- e << "--generate-xml-schema" << endl
- << " Generate a C++ header file as if the schema being\n"
- << " compiled defines the XML Schema namespace."
- << endl;
-
- e << "--extern-xml-schema <file>" << endl
- << " Generate code as if the XML Schema namespace was\n"
- << " defined in <file> and xsd:included in the schema\n"
- << " being compiled."
- << endl;
-
- e << "--suppress-parsing" << endl
- << " Suppress the generation of parsing functions."
- << endl;
-
- e << "--generate-element-type" << endl
- << " Generate types instead of parsing/serialization\n"
- << " functions for root elements."
- << endl;
-
- e << "--generate-element-map" << endl
- << " Generate a root element map that allows uniform\n"
- << " parsing/serialization of multiple root elements.\n"
- << endl;
-
- e << "--generate-intellisense" << endl
- << " Generate workarounds for IntelliSense bugs in\n"
- << " Visual Studio 2005 (8.0)."
- << endl;
-
- e << "--omit-default-attributes" << endl
- << " Omit attributes with default and fixed values\n"
- << " from serialized XML documents."
- << endl;
-
- e << "--namespace-map <xns>=<cns>" << endl
- << " Map XML Schema namespace <xns> to C++ namespace\n"
- << " <cns>. Repeat this option to specify mapping for\n"
- << " more than one XML Schema namespace."
- << endl;
-
- e << "--namespace-regex <regex>" << endl
- << " Add <regex> to the list of regular expressions\n"
- << " used to translate XML Schema namespace names to\n"
- << " C++ namespace names."
- << endl;
-
- e << "--namespace-regex-trace" << endl
- << " Trace the process of applying regular expressions\n"
- << " specified with the --namespace-regex option."
- << endl;
-
- e << "--reserved-name <name>" << endl
- << " Add <name> to the list of names that should not\n"
- << " be used as identifiers. The name can optionally\n"
- << " be followed by '=' and the replacement name that\n"
- << " should be used instead."
- << endl;
-
- e << "--type-naming <style>" << endl
- << " Specify the type naming convention that should be\n"
- << " used in the generated code. Valid styles are 'knr'\n"
- << " (default), 'ucc', and 'java'."
- << endl;
-
- e << "--function-naming <style>" << endl
- << " Specify the function naming convention that should\n"
- << " be used in the generated code. Valid styles are\n"
- << " 'knr' (default), 'lcc', and 'java'."
- << endl;
-
- e << "--type-regex <expr>" << endl
- << " Add <expr> to the list of regular expressions\n"
- << " used to translate XML Schema type names to C++\n"
- << " type names."
- << endl;
-
- e << "--accessor-regex <expr>" << endl
- << " Add <expr> to the list of regular expressions\n"
- << " used to translate XML Schema names of elements and\n"
- << " attributes to C++ accessor function names."
- << endl;
-
- e << "--one-accessor-regex <expr>" << endl
- << " Add <expr> to the list of regular expressions\n"
- << " used to translate XML Schema names of elements\n"
- << " and attributes with cardinality one to C++\n"
- << " accessor function names."
- << endl;
-
- e << "--opt-accessor-regex <expr>" << endl
- << " Add <expr> to the list of regular expressions\n"
- << " used to translate XML Schema names of elements\n"
- << " and attributes with cardinality optional to C++\n"
- << " accessor function names."
- << endl;
-
- e << "--seq-accessor-regex <expr>" << endl
- << " Add <expr> to the list of regular expressions\n"
- << " used to translate XML Schema names of elements\n"
- << " and attributes with cardinality sequence to C++\n"
- << " accessor function names."
- << endl;
-
- e << "--modifier-regex <expr>" << endl
- << " Add <expr> to the list of regular expressions\n"
- << " used to translate XML Schema names of elements and\n"
- << " attributes to C++ modifier function names."
- << endl;
-
- e << "--one-modifier-regex <expr>" << endl
- << " Add <expr> to the list of regular expressions\n"
- << " used to translate XML Schema names of elements\n"
- << " and attributes with cardinality one to C++\n"
- << " modifier function names."
- << endl;
-
- e << "--opt-modifier-regex <expr>" << endl
- << " Add <expr> to the list of regular expressions\n"
- << " used to translate XML Schema names of elements\n"
- << " and attributes with cardinality optional to C++\n"
- << " modifier function names."
- << endl;
-
- e << "--seq-modifier-regex <expr>" << endl
- << " Add <expr> to the list of regular expressions\n"
- << " used to translate XML Schema names of elements\n"
- << " and attributes with cardinality sequence to C++\n"
- << " modifier function names."
- << endl;
-
- e << "--parser-regex <expr>" << endl
- << " Add <expr> to the list of regular expressions\n"
- << " used to translate XML Schema element names to\n"
- << " C++ parsing function names."
- << endl;
-
- e << "--serializer-regex <expr>" << endl
- << " Add <expr> to the list of regular expressions\n"
- << " used to translate XML Schema element names to\n"
- << " C++ serialization function names."
- << endl;
-
- e << "--enumerator-regex <expr>" << endl
- << " Add <expr> to the list of regular expressions\n"
- << " used to translate XML Schema enumeration values\n"
- << " to C++ enumerator names."
- << endl;
-
- e << "--element-type-regex <expr>" << endl
- << " Add <expr> to the list of regular expressions\n"
- << " used to translate XML Schema element names to\n"
- << " C++ element type names."
- << endl;
-
- e << "--name-regex-trace" << endl
- << " Trace the process of applying regular expressions\n"
- << " specified with the name transformation options."
- << endl;
-
- e << "--include-with-brackets" << endl
- << " Use angle brackets (<>) instead of quotes (\"\") in\n"
- << " generated #include directives."
- << endl;
-
- e << "--include-prefix <prefix>" << endl
- << " Add <prefix> to generated #include directive\n"
- << " paths."
- << endl;
-
- e << "--include-regex <regex>" << endl
- << " Add <regex> to the list of regular expressions\n"
- << " used to transform #include directive paths."
- << endl;
-
- e << "--include-regex-trace" << endl
- << " Trace the process of applying regular expressions\n"
- << " specified with the --include-regex option."
- << endl;
-
- e << "--guard-prefix <prefix>" << endl
- << " Add <prefix> to generated header inclusion guards."
- << endl;
-
- e << "--root-element-first" << endl
- << " Treat only the first global element as a document\n"
- << " root."
- << endl;
-
- e << "--root-element-last" << endl
- << " Treat only the last global element as a document\n"
- << " root."
- << endl;
-
- e << "--root-element-all" << endl
- << " Treat all global elements as document roots."
- << endl;
-
- e << "--root-element-none" << endl
- << " Don't treat any global elements as document roots."
- << endl;
-
- e << "--root-element <element>" << endl
- << " Treat only <element> as a document root. Repeat\n"
- << " this option to specify more than one root element."
- << endl;
-
- e << "--custom-type <map>" << endl
- << " Use a custom C++ type instead of the generated\n"
- << " class. The <map> argument is in the form\n"
- << " name[=type[/base]], where <name> is a type name as\n"
- << " defined in XML Schema, <type> is a C++ type name\n"
- << " that should be used instead, and optional <base>\n"
- << " is a C++ name that should be given to the C++\n"
- << " class generated from the XML Schema definition\n"
- << " which is normally used as a base for the custom\n"
- << " type."
- << endl;
-
- e << "--custom-type-regex <regex>" << endl
- << " Use custom C++ types instead of the generated\n"
- << " classes. The <regex> argument is in the form\n"
- << " /name/[type/[base/]], where <name> is a regex\n"
- << " pattern that will be matched against type names\n"
- << " as defined in XML Schema, <type> is a C++ type\n"
- << " name that should be used instead, and optional\n"
- << " <base> is a C++ name that should be given to\n"
- << " the C++ class generated from the XML Schema\n"
- << " definition."
- << endl;
-
- e << "--hxx-suffix <suffix>" << endl
- << " Use <suffix> instead of the default '.hxx' to\n"
- << " construct the name of the header file."
- << endl;
-
- e << "--ixx-suffix <suffix>" << endl
- << " Use <suffix> instead of the default '.ixx' to\n"
- << " construct the name of the inline file."
- << endl;
-
- e << "--cxx-suffix <suffix>" << endl
- << " Use <suffix> instead of the default '.cxx' to\n"
- << " construct the name of the source file."
- << endl;
-
- e << "--fwd-suffix <suffix>" << endl
- << " Use <suffix> instead of the default '-fwd.hxx'\n"
- << " to construct the name of the forward declaration\n"
- << " file."
- << endl;
-
- e << "--hxx-regex <regex>" << endl
- << " Use <regex> to construct the name of the header\n"
- << " file."
- << endl;
-
- e << "--ixx-regex <regex>" << endl
- << " Use <regex> to construct the name of the inline\n"
- << " file."
- << endl;
-
- e << "--cxx-regex <regex>" << endl
- << " Use <regex> to construct the name of the source\n"
- << " file."
- << endl;
-
- e << "--fwd-regex <regex>" << endl
- << " Use <regex> to construct the name of the forward\n"
- << " declaration file."
- << endl;
-
- // Prologues.
- //
- e << "--hxx-prologue <text>" << endl
- << " Insert <text> at the beginning of the header file."
- << endl;
-
- e << "--ixx-prologue <text>" << endl
- << " Insert <text> at the beginning of the inline file."
- << endl;
-
- e << "--cxx-prologue <text>" << endl
- << " Insert <text> at the beginning of the source file."
- << endl;
-
- e << "--fwd-prologue <text>" << endl
- << " Insert <text> at the beginning of the forward\n"
- << " declaration file."
- << endl;
-
- e << "--prologue <text>" << endl
- << " Insert <text> at the beginning of each generated\n"
- << " file for which there is no file-specific prologue."
- << endl;
-
-
- // Epilogues.
- //
- e << "--hxx-epilogue <text>" << endl
- << " Insert <text> at the end of the header file."
- << endl;
-
- e << "--ixx-epilogue <text>" << endl
- << " Insert <text> at the end of the inline file."
- << endl;
-
- e << "--cxx-epilogue <text>" << endl
- << " Insert <text> at the end of the source file."
- << endl;
-
- e << "--fwd-epilogue <text>" << endl
- << " Insert <text> at the end of the forward\n"
- << " declaration file."
- << endl;
-
- e << "--epilogue <text>" << endl
- << " Insert <text> at the end of each generated file\n"
- << " for which there is no file-specific epilogue."
- << endl;
-
-
- // Prologue files.
- //
- e << "--hxx-prologue-file <file>" << endl
- << " Insert the content of the <file> at the beginning\n"
- << " of the header file."
- << endl;
-
- e << "--ixx-prologue-file <file>" << endl
- << " Insert the content of the <file> at the beginning\n"
- << " of the inline file."
- << endl;
-
- e << "--cxx-prologue-file <file>" << endl
- << " Insert the content of the <file> at the beginning\n"
- << " of the source file."
- << endl;
-
- e << "--fwd-prologue-file <file>" << endl
- << " Insert the content of the <file> at the beginning\n"
- << " of the forward declaration file."
- << endl;
-
- e << "--prologue-file <file>" << endl
- << " Insert the content of the <file> at the beginning\n"
- << " of each generated file for which there is no file-\n"
- << " specific prologue file."
- << endl;
-
- // Epilogue files.
- //
- e << "--hxx-epilogue-file <file>" << endl
- << " Insert the content of the <file> at the end of\n"
- << " the header file."
- << endl;
-
- e << "--ixx-epilogue-file <file>" << endl
- << " Insert the content of the <file> at the end of\n"
- << " the inline file."
- << endl;
-
- e << "--cxx-epilogue-file <file>" << endl
- << " Insert the content of the <file> at the end of\n"
- << " the source file."
- << endl;
-
- e << "--fwd-epilogue-file <file>" << endl
- << " Insert the content of the <file> at the end of\n"
- << " the forward declaration file."
- << endl;
-
- e << "--epilogue-file <file>" << endl
- << " Insert the content of the <file> at the end of\n"
- << " each generated file for which there is no file-\n"
- << " specific epilogue file."
- << endl;
-
- // Misc.
- //
- e << "--parts <num>" << endl
- << " Split generated source code into <num> parts."
- << endl;
-
- e << "--parts-suffix <suffix>" << endl
- << " Use <suffix> instead of the default '-' to\n"
- << " separate the file name from the part number."
- << endl;
-
- e << "--custom-literals <file>" << endl
- << " Load custom XML string to C++ literal mappings\n"
- << " from <file>."
- << endl;
-
- e << "--export-symbol <symbol>" << endl
- << " Export symbol for Win32 DLL export/import control."
- << endl;
-
- e << "--export-xml-schema" << endl
- << " Export/import types in the XML Schema namespace."
- << endl;
-
- e << "--export-maps" << endl
- << " Export polymorphism support maps from Win32 DLL."
- << endl;
-
- e << "--import-maps" << endl
- << " Import polymorphism support maps from Win32 DLL."
- << endl;
-
- e << "--show-anonymous" << endl
- << " Show elements and attributes that are of anonymous\n"
- << " types."
- << endl;
-
- e << "--show-sloc" << endl
- << " Show the number of generated physical source lines\n"
- << " of code (SLOC)."
- << endl;
-
- e << "--sloc-limit <num>" << endl
- << " Check that the number of generated physical source\n"
- << " lines of code (SLOC) does not exceed <num>."
- << endl;
-
- e << "--options-file <file>" << endl
- << " Read additional options from <file>. Each option\n"
- << " should appear on a separate line optionally\n"
- << " followed by space and an argument."
- << endl;
-
- e << "--proprietary-license" << endl
- << " Indicate that the generated code is licensed under\n"
- << " a proprietary license instead of the GPL."
- << endl;
+ CXX::Tree::options::print_usage (wcout);
+ CXX::options::print_usage (wcout);
}
- Tree::CLI::OptionsSpec Tree::Generator::
- options_spec ()
- {
- CLI::OptionsSpec spec;
-
- spec.option<CLI::char_type> ().default_value ("char");
-
- spec.option<CLI::hxx_suffix> ().default_value (".hxx");
- spec.option<CLI::ixx_suffix> ().default_value (".ixx");
- spec.option<CLI::cxx_suffix> ().default_value (".cxx");
- spec.option<CLI::fwd_suffix> ().default_value ("-fwd.hxx");
-
- spec.option<CLI::type_naming> ().default_value ("knr");
- spec.option<CLI::function_naming> ().default_value ("knr");
-
- spec.option<CLI::parts> ().default_value (1);
- spec.option<CLI::parts_suffix> ().default_value ("-");
-
- return spec;
- }
-
-
namespace
{
- Void
+ void
open (WideInputFileStream& ifs, NarrowString const& path)
{
try
{
-#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2
- Path fs_path (path, boost::filesystem::native);
-#else
- Path fs_path (path.c_str());
-#endif
- ifs.open (fs_path, std::ios_base::in | std::ios_base::binary);
+ Path fs_path (path);
+ ifs.open (fs_path.string ().c_str (),
+ std::ios_base::in | std::ios_base::binary);
if (!ifs.is_open ())
{
@@ -797,7 +142,7 @@ namespace CXX
}
}
- Void
+ void
append (WideOutputFileStream& os,
NarrowString const& path,
WideInputFileStream& default_is)
@@ -817,16 +162,15 @@ namespace CXX
}
}
- Void
+ void
append (WideOutputFileStream& os,
- Cult::Containers::Vector<NarrowString> const& primary,
- Cult::Containers::Vector<NarrowString> const& def)
+ NarrowStrings const& primary,
+ NarrowStrings const& def)
{
- Cult::Containers::Vector<NarrowString> const& v (
- primary.empty () ? def : primary);
+ NarrowStrings const& v (primary.empty () ? def : primary);
- for (Containers::Vector<NarrowString>::ConstIterator
- i (v.begin ()), e (v.end ()); i != e; ++i)
+ for (NarrowStrings::const_iterator i (v.begin ()), e (v.end ());
+ i != e; ++i)
{
os << i->c_str () << endl;
}
@@ -834,34 +178,30 @@ namespace CXX
}
- UnsignedLong Tree::Generator::
- generate (Tree::CLI::Options const& ops,
+ size_t Tree::Generator::
+ generate (Tree::options const& ops,
Schema& schema,
Path const& file_path,
- Boolean fpt,
+ bool fpt,
StringLiteralMap const& string_literal_map,
const WarningSet& disabled_warnings,
FileList& file_list,
AutoUnlinks& unlinks)
{
- using std::ios_base;
- namespace Indentation = BackendElements::Indentation;
-
- typedef BackendElements::Regex::Expression<Char> Regex;
-
- using Cult::Containers::Vector;
+ using cutl::shared_ptr;
+ typedef cutl::re::regexsub Regex;
- typedef Vector<Path> Paths;
- typedef Vector<Evptr<WideOutputFileStream> > WideOutputFileStreams;
+ typedef vector<Path> Paths;
+ typedef vector<shared_ptr<WideOutputFileStream> > WideOutputFileStreams;
try
{
// Do option validation.
//
- if (ops.value<CLI::parts> () < 1)
+ if (ops.parts () < 1)
{
wcerr << "error: invalid value for option --parts: " <<
- ops.value<CLI::parts> () << endl;
+ ops.parts () << endl;
throw Failed ();
}
@@ -893,8 +233,20 @@ namespace CXX
throw Failed ();
}
+ bool gen_cxx (!ops.generate_dep_only ());
+
+ // Process ordered types.
+ //
+ if (gen_cxx)
+ {
+ OrderProcessor proc;
+ if (!proc.process (ops, schema, file_path))
+ throw Failed ();
+ }
+
// Process names.
//
+ if (gen_cxx)
{
NameProcessor proc;
if (!proc.process (ops, schema, file_path, string_literal_map))
@@ -903,8 +255,9 @@ namespace CXX
// Process polymorphic types.
//
- if (ops.value<CLI::generate_polymorphic> () &&
- !ops.value<CLI::polymorphic_type_all> ())
+ if (gen_cxx &&
+ ops.generate_polymorphic () &&
+ !ops.polymorphic_type_all ())
{
PolymorphismProcessor proc;
if (!proc.process (ops, schema, file_path, disabled_warnings))
@@ -913,11 +266,9 @@ namespace CXX
// Parts.
//
- UnsignedLong parts (ops.value<CLI::parts> ());
- UnsignedLong units (
- counts.global_types + counts.generated_global_elements);
-
- UnsignedLong units_per_part (units / parts);
+ size_t parts (ops.parts ());
+ size_t units (counts.global_types + counts.generated_global_elements);
+ size_t units_per_part (units / parts);
if (parts != 1 && units_per_part < 1)
{
@@ -925,14 +276,14 @@ namespace CXX
throw Failed ();
}
- UnsignedLong complexity_per_part (counts.complexity_total / parts);
+ size_t complexity_per_part (counts.complexity_total / parts);
- NarrowString parts_suffix (ops.value<CLI::parts_suffix> ());
+ NarrowString parts_suffix (ops.parts_suffix ());
//
//
- Boolean generate_xml_schema (ops.value<CLI::generate_xml_schema> ());
+ bool generate_xml_schema (ops.generate_xml_schema ());
// We could be compiling several schemas at once in which case
// handling of the --generate-xml-schema option gets tricky: we
@@ -941,58 +292,68 @@ namespace CXX
//
if (generate_xml_schema)
{
- if (NarrowString name = ops.value<CLI::extern_xml_schema> ())
+ if (NarrowString name = ops.extern_xml_schema ())
{
-#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2
- if (file_path.native_file_string () != name)
-#else
if (file_path.string () != name)
-#endif
generate_xml_schema = false;
}
}
- Boolean inline_ (ops.value<CLI::generate_inline> () &&
- !generate_xml_schema);
+ bool header (true);
+ bool inline_ (ops.generate_inline () && !generate_xml_schema);
+ bool forward (ops.generate_forward () && !generate_xml_schema);
+ bool source (!generate_xml_schema);
+ bool gen_dep ((ops.generate_dep () || ops.generate_dep_only ()) &&
+ !generate_xml_schema);
- Boolean forward (ops.value<CLI::generate_forward> () &&
- !generate_xml_schema);
+ if (ops.generate_dep_only () && generate_xml_schema)
+ {
+ wcerr << "error: no dependency information can be generated for "
+ "XML Schema header" << endl;
+ throw Failed ();
+ }
- Boolean source (!generate_xml_schema);
+ if (gen_dep && fpt)
+ {
+ wcerr << "error: dependency generation not support in the " <<
+ "file-per-type mode" << endl;
+ throw Failed ();
+ }
// Generate code.
//
-#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2
- NarrowString name (file_path.leaf ());
-#else
- NarrowString name (file_path.filename ().string());
-#endif
-
- NarrowString hxx_suffix (ops.value <CLI::hxx_suffix> ());
- NarrowString ixx_suffix (ops.value <CLI::ixx_suffix> ());
- NarrowString cxx_suffix (ops.value <CLI::cxx_suffix> ());
- NarrowString fwd_suffix (ops.value <CLI::fwd_suffix> ());
-
- Regex hxx_expr (ops.value <CLI::hxx_regex> ().empty ()
+ NarrowString name (file_path.leaf ().string ());
+
+ NarrowString hxx_suffix (ops.hxx_suffix ());
+ NarrowString ixx_suffix (ops.ixx_suffix ());
+ NarrowString cxx_suffix (ops.cxx_suffix ());
+ NarrowString fwd_suffix (ops.fwd_suffix ());
+ NarrowString dep_suffix (ops.dep_suffix ());
+
+ Regex hxx_expr (ops.hxx_regex ().empty ()
? "#^(.+?)(\\.[^./\\\\]+)?$#$1" + hxx_suffix + "#"
- : ops.value <CLI::hxx_regex> ());
+ : ops.hxx_regex ());
- Regex ixx_expr (ops.value <CLI::ixx_regex> ().empty ()
+ Regex ixx_expr (ops.ixx_regex ().empty ()
? "#^(.+?)(\\.[^./\\\\]+)?$#$1" + ixx_suffix + "#"
- : ops.value <CLI::ixx_regex> ());
+ : ops.ixx_regex ());
- Regex cxx_expr (ops.value <CLI::cxx_regex> ().empty ()
+ Regex cxx_expr (ops.cxx_regex ().empty ()
? "#^(.+?)(\\.[^./\\\\]+)?$#$1" + cxx_suffix + "#"
- : ops.value <CLI::cxx_regex> ());
+ : ops.cxx_regex ());
- Regex fwd_expr (ops.value <CLI::fwd_regex> ().empty ()
+ Regex fwd_expr (ops.fwd_regex ().empty ()
? "#^(.+?)(\\.[^./\\\\]+)?$#$1" + fwd_suffix + "#"
- : ops.value <CLI::fwd_regex> ());
+ : ops.fwd_regex ());
+
+ Regex dep_expr (ops.dep_regex ().empty ()
+ ? "#^(.+?)(\\.[^./\\\\]+)?$#$1" + dep_suffix + "#"
+ : ops.dep_regex ());
- if (!hxx_expr.match (name))
+ if (header && !hxx_expr.match (name))
{
wcerr << "error: header expression '" <<
- hxx_expr.pattern () << "' does not match '" <<
+ hxx_expr.regex ().str ().c_str () << "' does not match '" <<
name.c_str () << "'" << endl;
throw Failed ();
}
@@ -1000,7 +361,7 @@ namespace CXX
if (inline_ && !ixx_expr.match (name))
{
wcerr << "error: inline expression '" <<
- ixx_expr.pattern () << "' does not match '" <<
+ ixx_expr.regex ().str ().c_str () << "' does not match '" <<
name.c_str () << "'" << endl;
throw Failed ();
}
@@ -1008,7 +369,7 @@ namespace CXX
if (source && parts == 1 && !cxx_expr.match (name))
{
wcerr << "error: source expression '" <<
- cxx_expr.pattern () << "' does not match '" <<
+ cxx_expr.regex ().str ().c_str () << "' does not match '" <<
name.c_str () << "'" << endl;
throw Failed ();
}
@@ -1016,31 +377,35 @@ namespace CXX
if (forward && !fwd_expr.match (name))
{
wcerr << "error: forward expression '" <<
- fwd_expr.pattern () << "' does not match '" <<
+ fwd_expr.regex ().str ().c_str () << "' does not match '" <<
name.c_str () << "'" << endl;
throw Failed ();
}
- NarrowString hxx_name (hxx_expr.merge (name));
- NarrowString ixx_name (inline_ ? ixx_expr.merge (name) : NarrowString ());
- NarrowString fwd_name (forward ? fwd_expr.merge (name) : NarrowString ());
-
-#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2
- Path hxx_path (hxx_name, boost::filesystem::native);
- Path ixx_path (ixx_name, boost::filesystem::native);
- Path fwd_path (fwd_name, boost::filesystem::native);
-#else
- Path hxx_path (hxx_name.c_str());
- Path ixx_path (ixx_name.c_str());
- Path fwd_path (fwd_name.c_str());
-#endif
+ if (gen_dep && !dep_expr.match (name))
+ {
+ wcerr << "error: dependency expression '" <<
+ dep_expr.regex ().str ().c_str () << "' does not match '" <<
+ name.c_str () << "'" << endl;
+ throw Failed ();
+ }
+
+ NarrowString hxx_name (header ? hxx_expr.replace (name) : NarrowString ());
+ NarrowString ixx_name (inline_ ? ixx_expr.replace (name) : NarrowString ());
+ NarrowString fwd_name (forward ? fwd_expr.replace (name) : NarrowString ());
+ NarrowString dep_name (gen_dep ? dep_expr.replace (name) : NarrowString ());
+
+ Path hxx_path (hxx_name);
+ Path ixx_path (ixx_name);
+ Path fwd_path (fwd_name);
+ Path dep_path (dep_name);
Paths cxx_paths;
if (source)
{
if (parts > 1)
{
- for (UnsignedLong i (0); i < parts; ++i)
+ for (size_t i (0); i < parts; ++i)
{
std::ostringstream os;
os << i;
@@ -1048,44 +413,30 @@ namespace CXX
Regex expr (
"#^(.+?)(\\.[^./\\\\]+)?$#$1" + parts_suffix + os.str () + "$2#");
- NarrowString part_name (expr.merge (name));
+ NarrowString part_name (expr.replace (name));
if (!cxx_expr.match (part_name))
{
wcerr << "error: source expression '" <<
- cxx_expr.pattern () << "' does not match '" <<
+ cxx_expr.regex ().str ().c_str () << "' does not match '" <<
part_name.c_str () << "'" << endl;
throw Failed ();
}
- cxx_paths.push_back (
-#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2
- Path (cxx_expr.merge (part_name), boost::filesystem::native));
-#else
- Path (cxx_expr.merge (part_name).c_str()));
-#endif
+ cxx_paths.push_back (Path (cxx_expr.replace (part_name)));
}
}
else
- cxx_paths.push_back (
-#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2
- Path (cxx_expr.merge (name), boost::filesystem::native));
-#else
- Path (cxx_expr.merge (name).c_str()));
-#endif
+ cxx_paths.push_back (Path (cxx_expr.replace (name)));
}
Path out_dir;
- if (NarrowString dir = ops.value<CLI::output_dir> ())
+ if (NarrowString dir = ops.output_dir ())
{
try
{
-#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2
- out_dir = Path (dir, boost::filesystem::native);
-#else
- out_dir = Path (dir.c_str());
-#endif
+ out_dir = Path (dir);
}
catch (InvalidPath const&)
{
@@ -1100,7 +451,7 @@ namespace CXX
// unless the user added the directory so that we propagate this
// to the output files.
//
- Path fpt_dir (file_path.branch_path ());
+ Path fpt_dir (file_path.directory ());
if (!fpt_dir.empty ())
out_dir /= fpt_dir;
@@ -1111,25 +462,42 @@ namespace CXX
hxx_path = out_dir / hxx_path;
ixx_path = out_dir / ixx_path;
fwd_path = out_dir / fwd_path;
+ dep_path = out_dir / dep_path;
- for (Paths::Iterator i (cxx_paths.begin ());
+ for (Paths::iterator i (cxx_paths.begin ());
i != cxx_paths.end (); ++i)
*i = out_dir / *i;
}
//
//
- WideOutputFileStream hxx (hxx_path, ios_base::out);
+ WideOutputFileStream hxx;
WideOutputFileStream ixx;
WideOutputFileStream fwd;
+ WideOutputFileStream dep;
WideOutputFileStreams cxx;
+ // DEP
+ //
+ if (gen_dep)
+ {
+ dep.open (dep_path.string ().c_str (), ios_base::out);
+
+ if (!dep.is_open ())
+ {
+ wcerr << dep_path << ": error: unable to open in write mode" << endl;
+ throw Failed ();
+ }
+
+ unlinks.add (dep_path);
+ file_list.push_back (dep_path.string ());
+ }
// FWD
//
- if (forward)
+ if (gen_cxx && forward)
{
- fwd.open (fwd_path, ios_base::out);
+ fwd.open (fwd_path.string ().c_str (), ios_base::out);
if (!fwd.is_open ())
{
@@ -1138,35 +506,30 @@ namespace CXX
}
unlinks.add (fwd_path);
-#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2
- file_list.push_back (fwd_path.native_file_string ());
-#else
file_list.push_back (fwd_path.string ());
-#endif
}
-
// HXX
//
- if (!hxx.is_open ())
+ if (gen_cxx && header)
{
- wcerr << hxx_path << ": error: unable to open in write mode" << endl;
- throw Failed ();
- }
+ hxx.open (hxx_path.string ().c_str (), ios_base::out);
- unlinks.add (hxx_path);
-#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2
- file_list.push_back (hxx_path.native_file_string ());
-#else
- file_list.push_back (hxx_path.string ());
-#endif
+ if (!hxx.is_open ())
+ {
+ wcerr << hxx_path << ": error: unable to open in write mode" << endl;
+ throw Failed ();
+ }
+ unlinks.add (hxx_path);
+ file_list.push_back (hxx_path.string ());
+ }
// IXX
//
- if (inline_)
+ if (gen_cxx && inline_)
{
- ixx.open (ixx_path, ios_base::out);
+ ixx.open (ixx_path.string ().c_str (), ios_base::out);
if (!ixx.is_open ())
{
@@ -1175,23 +538,19 @@ namespace CXX
}
unlinks.add (ixx_path);
-#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2
- file_list.push_back (ixx_path.native_file_string ());
-#else
file_list.push_back (ixx_path.string ());
-#endif
}
-
// CXX
//
- if (source)
+ if (gen_cxx && source)
{
- for (Paths::Iterator i (cxx_paths.begin ());
+ for (Paths::iterator i (cxx_paths.begin ());
i != cxx_paths.end (); ++i)
{
- Evptr<WideOutputFileStream> s (
- new WideOutputFileStream (*i, ios_base::out));
+ shared_ptr<WideOutputFileStream> s (
+ new (shared) WideOutputFileStream (
+ i->string ().c_str (), ios_base::out));
if (!s->is_open ())
{
@@ -1200,29 +559,23 @@ namespace CXX
}
unlinks.add (*i);
-#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2
- file_list.push_back (i->native_file_string ());
-#else
file_list.push_back (i->string ());
-#endif
cxx.push_back (s);
}
}
-
// Print copyright and license.
//
- Char const* copyright (
- ops.value<CLI::proprietary_license> ()
- ? copyright_proprietary
- : copyright_gpl);
+ char const* copyright (
+ ops.proprietary_license () ? copyright_proprietary : copyright_gpl);
- if (forward)
- fwd << copyright;
+ if (gen_cxx && header)
+ hxx << copyright;
- hxx << copyright;
+ if (gen_cxx && forward)
+ fwd << copyright;
- if (ops.value<CLI::generate_doxygen> ())
+ if (ops.generate_doxygen ())
{
// Use native path format.
//
@@ -1234,12 +587,12 @@ namespace CXX
}
- if (inline_)
+ if (gen_cxx && inline_)
ixx << copyright;
- if (source)
+ if (gen_cxx && source)
{
- for (WideOutputFileStreams::Iterator i (cxx.begin ());
+ for (WideOutputFileStreams::iterator i (cxx.begin ());
i != cxx.end (); ++i)
**i << copyright;
}
@@ -1249,7 +602,7 @@ namespace CXX
//
WideInputFileStream prologue;
{
- NarrowString name (ops.value<CLI::prologue_file> ());
+ NarrowString name (ops.prologue_file ());
if (name)
open (prologue, name);
@@ -1259,7 +612,7 @@ namespace CXX
//
WideInputFileStream epilogue;
{
- NarrowString name (ops.value<CLI::epilogue_file> ());
+ NarrowString name (ops.epilogue_file ());
if (name)
open (epilogue, name);
@@ -1267,27 +620,83 @@ namespace CXX
// SLOC counter.
//
- UnsignedLong sloc (0);
- Boolean show_sloc (ops.value<CLI::show_sloc> ());
+ size_t sloc_total (0);
+ bool show_sloc (ops.show_sloc ());
+
+ typedef
+ compiler::ostream_filter<compiler::cxx_indenter, wchar_t>
+ ind_filter;
+
+ typedef
+ compiler::ostream_filter<compiler::sloc_counter, wchar_t>
+ sloc_filter;
//
//
Regex guard_expr ("/([a-z])([A-Z])/$1_$2/"); // Split words.
- NarrowString guard_prefix (ops.value<CLI::guard_prefix> ());
+ NarrowString guard_prefix (ops.guard_prefix ());
if (!guard_prefix)
-#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2
- guard_prefix = file_path.branch_path ().native_directory_string ();
-#else
- guard_prefix = file_path.branch_path ().string ();
-#endif
+ guard_prefix = file_path.directory ().string ();
if (guard_prefix)
guard_prefix += '_';
+ // DEP
+ //
+ if (gen_dep)
+ {
+ NarrowString target;
+ NarrowStrings const& ts (ops.dep_target ());
+
+ if (!ts.empty ())
+ {
+ for (NarrowStrings::const_iterator i (ts.begin ());
+ i != ts.end (); ++i)
+ target += (target.empty () ? "" : " \\\n") + *i;
+ }
+ else
+ {
+ target = hxx_path.string ();
+
+ if (forward)
+ target += " \\\n" + fwd_path.string ();
+
+ if (inline_)
+ target += " \\\n" + ixx_path.string ();
+
+ for (Paths::iterator i (cxx_paths.begin ());
+ i != cxx_paths.end (); ++i)
+ target += " \\\n" + i->string ();
+
+ target += " \\\n" + dep_path.string ();
+ }
+
+ dep << target.c_str () << ':';
+
+ XSDFrontend::Generators::Dependencies gen;
+ Paths prq (gen.generate (schema, file_path));
+
+ for (Paths::iterator i (prq.begin ()); i != prq.end (); ++i)
+ dep << " \\" << endl
+ << " " << *i;
+
+ dep << endl;
+
+ // If requested, generate phony rules for included/imported schemas
+ // but not the main file which is the first in the list.
+ //
+ if (ops.dep_phony () && prq.size () > 1)
+ {
+ for (Paths::iterator i (prq.begin () + 1); i != prq.end (); ++i)
+ dep << endl
+ << *i << ':' << endl;
+ }
+ }
+
// FWD
//
- if (forward)
+ if (gen_cxx && forward)
{
Context ctx (fwd,
schema,
@@ -1300,11 +709,11 @@ namespace CXX
&hxx_expr,
&ixx_expr);
- Indentation::Clip<Indentation::SLOC, WideChar> fwd_sloc (fwd);
+ sloc_filter sloc (fwd);
// Guard
//
- String guard (guard_expr.merge (guard_prefix + fwd_name));
+ String guard (guard_expr.replace (guard_prefix + fwd_name));
guard = ctx.escape (guard); // make a c++ id
std::transform (guard.begin (), guard.end(), guard.begin (), upcase);
@@ -1312,15 +721,46 @@ namespace CXX
<< "#define " << guard << endl
<< endl;
+ if (ctx.std >= cxx_version::cxx11)
+ {
+ fwd << "#ifndef XSD_CXX11" << endl
+ << "#define XSD_CXX11" << endl
+ << "#endif" << endl
+ << endl;
+ }
+
+ if (ctx.char_type == L"char")
+ {
+ fwd << "#ifndef XSD_USE_CHAR" << endl
+ << "#define XSD_USE_CHAR" << endl
+ << "#endif" << endl
+ << endl;
+
+ fwd << "#ifndef XSD_CXX_TREE_USE_CHAR" << endl
+ << "#define XSD_CXX_TREE_USE_CHAR" << endl
+ << "#endif" << endl
+ << endl;
+ }
+ else if (ctx.char_type == L"wchar_t")
+ {
+ fwd << "#ifndef XSD_USE_WCHAR" << endl
+ << "#define XSD_USE_WCHAR" << endl
+ << "#endif" << endl
+ << endl;
+
+ fwd << "#ifndef XSD_CXX_TREE_USE_WCHAR" << endl
+ << "#define XSD_CXX_TREE_USE_WCHAR" << endl
+ << "#endif" << endl
+ << endl;
+ }
+
// Copy prologue.
//
fwd << "// Begin prologue." << endl
<< "//" << endl;
- append (fwd,
- ops.value<CLI::fwd_prologue> (),
- ops.value<CLI::prologue> ());
- append (fwd, ops.value<CLI::fwd_prologue_file> (), prologue);
+ append (fwd, ops.fwd_prologue (), ops.prologue ());
+ append (fwd, ops.fwd_prologue_file (), prologue);
fwd << "//" << endl
<< "// End prologue." << endl
@@ -1333,59 +773,28 @@ namespace CXX
<< "#if (XSD_INT_VERSION != " << XSD_INT_VERSION << "L)" << endl
<< "#error XSD runtime version mismatch" << endl
<< "#endif" << endl
-
<< endl;
- {
- fwd << "#include <xsd/cxx/pre.hxx>" << endl
- << endl;
-
- if (ctx.char_type == L"char")
- {
- fwd << "#ifndef XSD_USE_CHAR" << endl
- << "#define XSD_USE_CHAR" << endl
- << "#endif" << endl
- << endl;
-
- fwd << "#ifndef XSD_CXX_TREE_USE_CHAR" << endl
- << "#define XSD_CXX_TREE_USE_CHAR" << endl
- << "#endif" << endl
- << endl;
- }
- else if (ctx.char_type == L"wchar_t")
- {
- fwd << "#ifndef XSD_USE_WCHAR" << endl
- << "#define XSD_USE_WCHAR" << endl
- << "#endif" << endl
- << endl;
-
- fwd << "#ifndef XSD_CXX_TREE_USE_WCHAR" << endl
- << "#define XSD_CXX_TREE_USE_WCHAR" << endl
- << "#endif" << endl
- << endl;
- }
-
- // Set auto-indentation.
- //
- Indentation::Clip<Indentation::CXX, WideChar> fwd_clip (fwd);
+ fwd << "#include <xsd/cxx/pre.hxx>" << endl
+ << endl;
- // Generate.
- //
+ // Generate.
+ //
+ {
+ ind_filter ind (fwd); // We don't want to indent prologues/epilogues.
generate_forward (ctx);
-
- fwd << "#include <xsd/cxx/post.hxx>" << endl
- << endl;
}
+ fwd << "#include <xsd/cxx/post.hxx>" << endl
+ << endl;
+
// Copy epilogue.
//
fwd << "// Begin epilogue." << endl
<< "//" << endl;
- append (fwd, ops.value<CLI::fwd_epilogue_file> (), epilogue);
- append (fwd,
- ops.value<CLI::fwd_epilogue> (),
- ops.value<CLI::epilogue> ());
+ append (fwd, ops.fwd_epilogue_file (), epilogue);
+ append (fwd, ops.fwd_epilogue (), ops.epilogue ());
fwd << "//" << endl
<< "// End epilogue." << endl
@@ -1394,16 +803,14 @@ namespace CXX
fwd << "#endif // " << guard << endl;
if (show_sloc)
- {
- wcerr << fwd_path << ": "
- << fwd_sloc.buffer ().count () << endl;
+ wcerr << fwd_path << ": " << sloc.stream ().count () << endl;
- sloc += fwd_sloc.buffer ().count ();
- }
+ sloc_total += sloc.stream ().count ();
}
// HXX
//
+ if (gen_cxx && header)
{
Context ctx (hxx,
schema,
@@ -1416,11 +823,11 @@ namespace CXX
&hxx_expr,
&ixx_expr);
- Indentation::Clip<Indentation::SLOC, WideChar> hxx_sloc (hxx);
+ sloc_filter sloc (hxx);
// Guard
//
- String guard (guard_expr.merge (guard_prefix + hxx_name));
+ String guard (guard_expr.replace (guard_prefix + hxx_name));
guard = ctx.escape (guard); // make a c++ id
std::transform (guard.begin (), guard.end(), guard.begin (), upcase);
@@ -1428,14 +835,57 @@ namespace CXX
<< "#define " << guard << endl
<< endl;
+ if (!forward)
+ {
+ if (ctx.std >= cxx_version::cxx11)
+ {
+ hxx << "#ifndef XSD_CXX11" << endl
+ << "#define XSD_CXX11" << endl
+ << "#endif" << endl
+ << endl;
+ }
+
+ if (ctx.char_type == L"char")
+ {
+ hxx << "#ifndef XSD_USE_CHAR" << endl
+ << "#define XSD_USE_CHAR" << endl
+ << "#endif" << endl
+ << endl;
+
+ hxx << "#ifndef XSD_CXX_TREE_USE_CHAR" << endl
+ << "#define XSD_CXX_TREE_USE_CHAR" << endl
+ << "#endif" << endl
+ << endl;
+ }
+ else if (ctx.char_type == L"wchar_t")
+ {
+ hxx << "#ifndef XSD_USE_WCHAR" << endl
+ << "#define XSD_USE_WCHAR" << endl
+ << "#endif" << endl
+ << endl;
+
+ hxx << "#ifndef XSD_CXX_TREE_USE_WCHAR" << endl
+ << "#define XSD_CXX_TREE_USE_WCHAR" << endl
+ << "#endif" << endl
+ << endl;
+ }
+ }
+ else if (!generate_xml_schema)
+ {
+ // Generate it before the prologue so that we get the above
+ // defines.
+ //
+ hxx << "#include " << ctx.process_include_path (fwd_name)
+ << endl << endl;
+ }
+
// Copy prologue.
//
hxx << "// Begin prologue." << endl
<< "//" << endl;
- append (
- hxx, ops.value<CLI::hxx_prologue> (), ops.value<CLI::prologue> ());
- append (hxx, ops.value<CLI::hxx_prologue_file> (), prologue);
+ append (hxx, ops.hxx_prologue (), ops.prologue ());
+ append (hxx, ops.hxx_prologue_file (), prologue);
hxx << "//" << endl
<< "// End prologue." << endl
@@ -1450,95 +900,53 @@ namespace CXX
<< "#endif" << endl
<< endl;
- {
- hxx << "#include <xsd/cxx/pre.hxx>" << endl
- << endl;
-
- // Generate character selection defines.
- //
- if (!forward)
- {
- if (ctx.char_type == L"char")
- {
- hxx << "#ifndef XSD_USE_CHAR" << endl
- << "#define XSD_USE_CHAR" << endl
- << "#endif" << endl
- << endl;
-
- hxx << "#ifndef XSD_CXX_TREE_USE_CHAR" << endl
- << "#define XSD_CXX_TREE_USE_CHAR" << endl
- << "#endif" << endl
- << endl;
- }
- else if (ctx.char_type == L"wchar_t")
- {
- hxx << "#ifndef XSD_USE_WCHAR" << endl
- << "#define XSD_USE_WCHAR" << endl
- << "#endif" << endl
- << endl;
-
- hxx << "#ifndef XSD_CXX_TREE_USE_WCHAR" << endl
- << "#define XSD_CXX_TREE_USE_WCHAR" << endl
- << "#endif" << endl
- << endl;
- }
- }
-
- // Set auto-indentation.
- //
- Indentation::Clip<Indentation::CXX, WideChar> hxx_clip (hxx);
+ hxx << "#include <xsd/cxx/pre.hxx>" << endl
+ << endl;
+ // Generate.
+ //
+ {
+ ind_filter ind (hxx); // We don't want to indent prologues/epilogues.
- // Generate.
- //
- if (!generate_xml_schema)
- {
- if (forward)
- hxx << "#include " << ctx.process_include_path (fwd_name)
- << endl << endl;
- else
- generate_forward (ctx);
- }
+ if (!generate_xml_schema && !forward)
+ generate_forward (ctx);
generate_tree_header (ctx);
if (!generate_xml_schema)
{
-
- if (ops.value<CLI::generate_ostream> ())
+ if (ops.generate_ostream ())
generate_stream_header (ctx);
- if (!ops.value<CLI::generate_element_type> () &&
- !ops.value<CLI::suppress_parsing> ())
+ if (!ops.generate_element_type () && !ops.suppress_parsing ())
generate_parser_header (ctx);
- if (ops.value<CLI::generate_serialization> ())
+ if (ops.generate_serialization ())
generate_serialization_header (ctx);
- if (!ops.value<CLI::generate_insertion> ().empty ())
+ if (!ops.generate_insertion ().empty ())
generate_stream_insertion_header (ctx);
}
+ }
- if (inline_)
- {
- hxx << "#ifndef XSD_DONT_INCLUDE_INLINE" << endl
- << "#include " << ctx.process_include_path (ixx_name) << endl
- << "#endif // XSD_DONT_INCLUDE_INLINE" << endl
- << endl;
- }
-
- hxx << "#include <xsd/cxx/post.hxx>" << endl
+ if (inline_)
+ {
+ hxx << "#ifndef XSD_DONT_INCLUDE_INLINE" << endl
+ << "#include " << ctx.process_include_path (ixx_name) << endl
+ << "#endif // XSD_DONT_INCLUDE_INLINE" << endl
<< endl;
}
+ hxx << "#include <xsd/cxx/post.hxx>" << endl
+ << endl;
+
// Copy epilogue.
//
hxx << "// Begin epilogue." << endl
<< "//" << endl;
- append (hxx, ops.value<CLI::hxx_epilogue_file> (), epilogue);
- append (
- hxx, ops.value<CLI::hxx_epilogue> (), ops.value<CLI::epilogue> ());
+ append (hxx, ops.hxx_epilogue_file (), epilogue);
+ append (hxx, ops.hxx_epilogue (), ops.epilogue ());
hxx << "//" << endl
<< "// End epilogue." << endl
@@ -1547,18 +955,15 @@ namespace CXX
hxx << "#endif // " << guard << endl;
if (show_sloc)
- {
- wcerr << hxx_path << ": "
- << hxx_sloc.buffer ().count () << endl;
+ wcerr << hxx_path << ": " << sloc.stream ().count () << endl;
- sloc += hxx_sloc.buffer ().count ();
- }
+ sloc_total += sloc.stream ().count ();
}
// IXX
//
- if (inline_)
+ if (gen_cxx && inline_)
{
Context ctx (ixx,
schema,
@@ -1571,11 +976,11 @@ namespace CXX
&hxx_expr,
&ixx_expr);
- Indentation::Clip<Indentation::SLOC, WideChar> ixx_sloc (ixx);
+ sloc_filter sloc (ixx);
// Guard
//
- String guard (guard_expr.merge (guard_prefix + ixx_name));
+ String guard (guard_expr.replace (guard_prefix + ixx_name));
guard = ctx.escape (guard); // make a c++ id
std::transform (guard.begin (), guard.end(), guard.begin (), upcase);
@@ -1588,22 +993,17 @@ namespace CXX
ixx << "// Begin prologue." << endl
<< "//" << endl;
- append (
- ixx, ops.value<CLI::ixx_prologue> (), ops.value<CLI::prologue> ());
- append (ixx, ops.value<CLI::ixx_prologue_file> (), prologue);
+ append (ixx, ops.ixx_prologue (), ops.prologue ());
+ append (ixx, ops.ixx_prologue_file (), prologue);
ixx << "//" << endl
<< "// End prologue." << endl
<< endl;
+ // Generate.
+ //
{
- // Set auto-indentation.
- //
- Indentation::Clip<Indentation::CXX, WideChar> ixx_clip (ixx);
-
-
- // Generate.
- //
+ ind_filter ind (ixx); // We don't want to indent prologues/epilogues.
generate_tree_inline (ctx, 1, 0);
}
@@ -1612,9 +1012,8 @@ namespace CXX
ixx << "// Begin epilogue." << endl
<< "//" << endl;
- append (ixx, ops.value<CLI::ixx_epilogue_file> (), epilogue);
- append (
- ixx, ops.value<CLI::ixx_epilogue> (), ops.value<CLI::epilogue> ());
+ append (ixx, ops.ixx_epilogue_file (), epilogue);
+ append (ixx, ops.ixx_epilogue (), ops.epilogue ());
ixx << "//" << endl
<< "// End epilogue." << endl
@@ -1623,31 +1022,26 @@ namespace CXX
ixx << "#endif // " << guard.c_str () << endl;
if (show_sloc)
- {
- wcerr << ixx_path << ": "
- << ixx_sloc.buffer ().count () << endl;
+ wcerr << ixx_path << ": " << sloc.stream ().count () << endl;
- sloc += ixx_sloc.buffer ().count ();
- }
+ sloc_total += sloc.stream ().count ();
}
-
// CXX
//
-
- if (source)
+ if (gen_cxx && source)
{
- UnsignedLong first_unit (0); // First unit in the current part.
+ size_t first_unit (0); // First unit in the current part.
- for (UnsignedLong part (0); part < parts; ++part)
+ for (size_t part (0); part < parts; ++part)
{
// Figure out the range of units for this part.
//
- UnsignedLong last_unit (first_unit);
+ size_t last_unit (first_unit);
if (units != 0)
{
- UnsignedLong complexity (counts.complexity[last_unit]);
+ size_t complexity (counts.complexity[last_unit]);
while (complexity < complexity_per_part)
{
@@ -1660,7 +1054,7 @@ namespace CXX
// Check if the increase in complexity should be kept in this
// part or moved to the next.
//
- UnsignedLong new_complexity (
+ size_t new_complexity (
complexity + counts.complexity[last_unit + 1]);
if (new_complexity > complexity_per_part)
@@ -1684,8 +1078,8 @@ namespace CXX
//
//
- UnsignedLong first (first_unit);
- UnsignedLong last (last_unit);
+ size_t first (first_unit);
+ size_t last (last_unit);
first_unit = last_unit + 1;
@@ -1705,86 +1099,78 @@ namespace CXX
&hxx_expr,
&ixx_expr);
- Indentation::Clip<Indentation::SLOC, WideChar> cxx_sloc (os);
+ sloc_filter sloc (os);
// Copy prologue.
//
os << "// Begin prologue." << endl
<< "//" << endl;
- append (os,
- ops.value<CLI::cxx_prologue> (),
- ops.value<CLI::prologue> ());
- append (os, ops.value<CLI::cxx_prologue_file> (), prologue);
+ append (os, ops.cxx_prologue (), ops.prologue ());
+ append (os, ops.cxx_prologue_file (), prologue);
os << "//" << endl
<< "// End prologue." << endl
<< endl;
- {
- os << "#include <xsd/cxx/pre.hxx>" << endl
- << endl;
-
- // Set auto-indentation.
- //
- Indentation::Clip<Indentation::CXX, WideChar> cxx_clip (os);
+ os << "#include <xsd/cxx/pre.hxx>" << endl
+ << endl;
+ os << "#include " << ctx.process_include_path (hxx_name) << endl
+ << endl;
- // Generate.
+ // Generate.
+ //
+ {
+ // We don't want to indent prologues/epilogues.
//
- os << "#include " << ctx.process_include_path (hxx_name) << endl
- << endl;
+ ind_filter ind (os);
if (!inline_)
generate_tree_inline (ctx, first, last);
generate_tree_source (ctx, first, last);
- if (ops.value<CLI::generate_ostream> ())
+ if (ops.generate_ostream ())
generate_stream_source (ctx, first, last);
- if (!ops.value<CLI::generate_element_type> () &&
- !ops.value<CLI::suppress_parsing> ())
+ if (!ops.generate_element_type () && !ops.suppress_parsing ())
generate_parser_source (ctx, first, last);
- if (ops.value<CLI::generate_serialization> ())
+ if (ops.generate_serialization ())
generate_serialization_source (ctx, first, last);
- if (!ops.value<CLI::generate_extraction> ().empty ())
+ if (!ops.generate_extraction ().empty ())
generate_stream_extraction_source (ctx);
- if (!ops.value<CLI::generate_insertion> ().empty ())
+ if (!ops.generate_insertion ().empty ())
generate_stream_insertion_source (ctx);
-
- os << "#include <xsd/cxx/post.hxx>" << endl
- << endl;
}
+ os << "#include <xsd/cxx/post.hxx>" << endl
+ << endl;
+
// Copy epilogue.
//
os << "// Begin epilogue." << endl
<< "//" << endl;
- append (os, ops.value<CLI::cxx_epilogue_file> (), epilogue);
- append (os,
- ops.value<CLI::cxx_epilogue> (),
- ops.value<CLI::epilogue> ());
+ append (os, ops.cxx_epilogue_file (), epilogue);
+ append (os, ops.cxx_epilogue (), ops.epilogue ());
os << "//" << endl
<< "// End epilogue." << endl
<< endl;
if (show_sloc)
- {
- wcerr << cxx_paths[part] << ": "
- << cxx_sloc.buffer ().count () << endl;
+ wcerr << cxx_paths[part] << ": " << sloc.stream ().count ()
+ << endl;
- sloc += cxx_sloc.buffer ().count ();
- }
+ sloc_total += sloc.stream ().count ();
}
}
- return sloc;
+ return sloc_total;
}
catch (UnrepresentableCharacter const& e)
{
@@ -1823,18 +1209,18 @@ namespace CXX
throw Failed ();
}
- catch (BackendElements::Regex::Format<Char> const& e)
+ catch (cutl::re::format const& e)
{
wcerr << "error: invalid regex: '" <<
- e.expression ().c_str () << "': " <<
+ e.regex ().c_str () << "': " <<
e.description ().c_str () << endl;
throw Failed ();
}
- catch (BackendElements::Regex::Format<WideChar> const& e)
+ catch (cutl::re::wformat const& e)
{
wcerr << "error: invalid regex: '" <<
- e.expression () << "': " << e.description () << endl;
+ e.regex () << "': " << e.description ().c_str () << endl;
throw Failed ();
}
diff --git a/xsd/xsd/cxx/tree/generator.hxx b/xsd/xsd/cxx/tree/generator.hxx
index 2e50392..f81f8e3 100644
--- a/xsd/xsd/cxx/tree/generator.hxx
+++ b/xsd/xsd/cxx/tree/generator.hxx
@@ -1,43 +1,36 @@
// file : xsd/cxx/tree/generator.hxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#ifndef CXX_TREE_GENERATOR_HXX
#define CXX_TREE_GENERATOR_HXX
-#include <cult/types.hxx>
-
#include <xsd-frontend/semantic-graph/elements.hxx> // Path
#include <xsd-frontend/semantic-graph/schema.hxx>
#include <xsd.hxx>
+#include <types.hxx>
#include <cxx/literal-map.hxx>
-#include <cxx/tree/cli.hxx>
+#include <cxx/tree/options.hxx>
namespace CXX
{
namespace Tree
{
- using namespace Cult::Types;
-
class Generator
{
public:
- static Void
+ static void
usage ();
- static CLI::OptionsSpec
- options_spec ();
-
struct Failed {};
- static UnsignedLong
- generate (CLI::Options const& options,
+ static size_t
+ generate (options const&,
XSDFrontend::SemanticGraph::Schema&,
XSDFrontend::SemanticGraph::Path const& file,
- Boolean file_per_type,
+ bool file_per_type,
StringLiteralMap const&,
const WarningSet& disabled_warnings,
FileList& file_list,
diff --git a/xsd/xsd/cxx/tree/name-processor.cxx b/xsd/xsd/cxx/tree/name-processor.cxx
index 4949bed..1f3844b 100644
--- a/xsd/xsd/cxx/tree/name-processor.cxx
+++ b/xsd/xsd/cxx/tree/name-processor.cxx
@@ -1,51 +1,45 @@
// file : xsd/cxx/tree/name-processor.cxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2006-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2006-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+#include <set>
+#include <map>
+#include <vector>
#include <sstream>
#include <iostream>
-#include <cult/containers/set.hxx>
-#include <cult/containers/map.hxx>
-#include <cult/containers/vector.hxx>
-
-#include <backend-elements/regex.hxx>
+#include <cutl/re.hxx>
#include <cxx/tree/default-value.hxx>
#include <cxx/tree/name-processor.hxx>
+using namespace std;
+
namespace CXX
{
namespace Tree
{
- NameProcessor::
- NameProcessor ()
- {
- // Dummy ctor, helps with long symbols on HP-UX.
- }
-
namespace
{
//
//
- typedef Cult::Containers::Set<String> NameSet;
+ typedef set<String> NameSet;
class Context: public Tree::Context
{
public:
struct Failed {};
- Context (CLI::Options const& options,
+ Context (Tree::options const& ops,
Counts const& counts,
- Boolean generate_xml_schema,
+ bool generate_xml_schema,
SemanticGraph::Schema& root,
SemanticGraph::Path const& path,
StringLiteralMap const& map)
: Tree::Context (std::wcerr,
root,
path,
- options,
+ ops,
counts,
generate_xml_schema,
&map,
@@ -54,7 +48,7 @@ namespace CXX
0),
global_type_names (global_type_names_),
global_element_names (global_element_names_),
- detach (options.value<CLI::generate_detach> ()),
+ detach (ops.generate_detach ()),
type_regex (type_regex_),
accessor_regex (accessor_regex_),
one_accessor_regex (one_accessor_regex_),
@@ -66,14 +60,12 @@ namespace CXX
seq_modifier_regex (seq_modifier_regex_),
parser_regex (parser_regex_),
serializer_regex (serializer_regex_),
+ const_regex (const_regex_),
enumerator_regex (enumerator_regex_),
element_type_regex (element_type_regex_)
{
- typedef Containers::Vector<NarrowString> Vector;
-
- NarrowString tn (options.value<CLI::type_naming> ());
- NarrowString fn (options.value<CLI::function_naming> ());
-
+ NarrowString tn (options.type_naming ());
+ NarrowString fn (options.function_naming ());
// Type name regex.
//
@@ -116,9 +108,7 @@ namespace CXX
}
- compile_regex (options.value<CLI::type_regex> (),
- type_regex,
- "type");
+ compile_regex (options.type_regex (), type_regex, "type");
}
// Accessor name regex.
@@ -149,24 +139,23 @@ namespace CXX
accessor_regex.push_back ("/([^,]+)/get\\u$1/");
}
- compile_regex (options.value<CLI::accessor_regex> (),
+ compile_regex (options.accessor_regex (),
accessor_regex,
"accessor");
- compile_regex (options.value<CLI::one_accessor_regex> (),
+ compile_regex (options.one_accessor_regex (),
one_accessor_regex,
"one accessor");
- compile_regex (options.value<CLI::opt_accessor_regex> (),
+ compile_regex (options.opt_accessor_regex (),
opt_accessor_regex,
"optional accessor");
- compile_regex (options.value<CLI::seq_accessor_regex> (),
+ compile_regex (options.seq_accessor_regex (),
seq_accessor_regex,
"sequence accessor");
}
-
// Modifier name regex.
//
{
@@ -190,24 +179,23 @@ namespace CXX
modifier_regex.push_back ("/detach,([^,]+)/detach\\u$1/");
}
- compile_regex (options.value<CLI::modifier_regex> (),
+ compile_regex (options.modifier_regex (),
modifier_regex,
"modifier");
- compile_regex (options.value<CLI::one_modifier_regex> (),
+ compile_regex (options.one_modifier_regex (),
one_modifier_regex,
"one modifier");
- compile_regex (options.value<CLI::opt_modifier_regex> (),
+ compile_regex (options.opt_modifier_regex (),
opt_modifier_regex,
"optional modifier");
- compile_regex (options.value<CLI::seq_modifier_regex> (),
+ compile_regex (options.seq_modifier_regex (),
seq_modifier_regex,
"sequence modifier");
}
-
// Parser name regex.
//
{
@@ -222,9 +210,7 @@ namespace CXX
parser_regex.push_back ("/(.+)/parse\\u$1/");
}
- compile_regex (options.value<CLI::parser_regex> (),
- parser_regex,
- "parser");
+ compile_regex (options.parser_regex (), parser_regex, "parser");
}
// Serializer name regex.
@@ -241,11 +227,35 @@ namespace CXX
serializer_regex.push_back ("/(.+)/serialize\\u$1/");
}
- compile_regex (options.value<CLI::serializer_regex> (),
+ compile_regex (options.serializer_regex (),
serializer_regex,
"serializer");
}
+ // Const regex.
+ //
+ {
+ if (fn == "knr")
+ {
+ const_regex.push_back ("/([^,]+),([^,]+),([^,]+)/$1_$2_$3/");
+ const_regex.push_back ("/([^,]+),([^,]+)/$1_$2/");
+ }
+ else if (fn == "lcc")
+ {
+ const_regex.push_back ("/([^,]+),([^,]+),([^,]+)/\\l$1_\\u$2_\\u$3/");
+ const_regex.push_back ("/([^,]+),([^,]+)/\\l$1\\u$2/");
+ }
+ else
+ {
+ // Java: all uppercase.
+ //
+ const_regex.push_back ("/([^,]+),([^,]+),([^,]+)/\\U$1_$2_$3/");
+ const_regex.push_back ("/([^,]+),([^,]+)/\\U$1_$2/");
+ }
+
+ compile_regex (options.const_regex (), const_regex, "const");
+ }
+
// Enumerator name regex.
//
{
@@ -253,14 +263,14 @@ namespace CXX
//
enumerator_regex.push_back ("/^$/empty/");
- compile_regex (options.value<CLI::enumerator_regex> (),
+ compile_regex (options.enumerator_regex (),
enumerator_regex,
"enumerator");
}
// Element type regex.
//
- compile_regex (options.value<CLI::element_type_regex> (),
+ compile_regex (options.element_type_regex (),
element_type_regex,
"element_type");
}
@@ -282,35 +292,44 @@ namespace CXX
seq_modifier_regex (c.seq_modifier_regex),
parser_regex (c.parser_regex),
serializer_regex (c.serializer_regex),
+ const_regex (c.const_regex),
enumerator_regex (c.enumerator_regex),
element_type_regex (c.element_type_regex)
{
}
public:
- typedef BackendElements::Regex::Expression<WideChar> Regex;
- typedef BackendElements::Regex::Format<WideChar> RegexFormat;
- typedef Cult::Containers::Vector<Regex> RegexVector;
+ typedef cutl::re::wregexsub Regex;
+ typedef cutl::re::wformat RegexFormat;
+
+ struct RegexVector: vector<Regex>
+ {
+ void
+ push_back (String const& r)
+ {
+ vector<Regex>::push_back (Regex (r));
+ }
+ };
String
process_regex (String const& name,
RegexVector const& rv,
String const& id)
{
- Boolean trace (options.value<CLI::name_regex_trace> ());
+ bool trace (options.name_regex_trace ());
if (trace)
os << id << " name: '" << name << "'" << endl;
- for (RegexVector::ConstReverseIterator i (rv.rbegin ());
+ for (RegexVector::const_reverse_iterator i (rv.rbegin ());
i != rv.rend (); ++i)
{
if (trace)
- os << "try: '" << i->pattern () << "' : ";
+ os << "try: '" << i->regex () << "' : ";
if (i->match (name))
{
- String r (i->merge (name));
+ String r (i->replace (name));
if (trace)
os << "'" << r << "' : +" << endl;
@@ -331,20 +350,20 @@ namespace CXX
RegexVector const& backup,
String const& id)
{
- Boolean trace (options.value<CLI::name_regex_trace> ());
+ bool trace (options.name_regex_trace ());
if (trace)
os << id << " name: '" << name << "'" << endl;
- for (RegexVector::ConstReverseIterator i (primary.rbegin ());
+ for (RegexVector::const_reverse_iterator i (primary.rbegin ());
i != primary.rend (); ++i)
{
if (trace)
- os << "try: '" << i->pattern () << "' : ";
+ os << "try: '" << i->regex () << "' : ";
if (i->match (name))
{
- String r (i->merge (name));
+ String r (i->replace (name));
if (trace)
os << "'" << r << "' : +" << endl;
@@ -356,15 +375,15 @@ namespace CXX
os << '-' << endl;
}
- for (RegexVector::ConstReverseIterator i (backup.rbegin ());
+ for (RegexVector::const_reverse_iterator i (backup.rbegin ());
i != backup.rend (); ++i)
{
if (trace)
- os << "try: '" << i->pattern () << "' : ";
+ os << "try: '" << i->regex () << "' : ";
if (i->match (name))
{
- String r (i->merge (name));
+ String r (i->replace (name));
if (trace)
os << "'" << r << "' : +" << endl;
@@ -386,20 +405,20 @@ namespace CXX
String const& id)
{
String s (ns + L' ' + name);
- Boolean trace (options.value<CLI::name_regex_trace> ());
+ bool trace (options.name_regex_trace ());
if (trace)
os << id << " name: '" << s << "'" << endl;
- for (RegexVector::ConstReverseIterator i (rv.rbegin ());
+ for (RegexVector::const_reverse_iterator i (rv.rbegin ());
i != rv.rend (); ++i)
{
if (trace)
- os << "try: '" << i->pattern () << "' : ";
+ os << "try: '" << i->regex () << "' : ";
if (i->match (s))
{
- String r (i->merge (s));
+ String r (i->replace (s));
if (trace)
os << "'" << r << "' : +" << endl;
@@ -422,20 +441,20 @@ namespace CXX
String const& id)
{
String s (ns + L' ' + name);
- Boolean trace (options.value<CLI::name_regex_trace> ());
+ bool trace (options.name_regex_trace ());
if (trace)
os << id << " name: '" << s << "'" << endl;
- for (RegexVector::ConstReverseIterator i (primary.rbegin ());
+ for (RegexVector::const_reverse_iterator i (primary.rbegin ());
i != primary.rend (); ++i)
{
if (trace)
- os << "try: '" << i->pattern () << "' : ";
+ os << "try: '" << i->regex () << "' : ";
if (i->match (s))
{
- String r (i->merge (s));
+ String r (i->replace (s));
if (trace)
os << "'" << r << "' : +" << endl;
@@ -447,15 +466,15 @@ namespace CXX
os << '-' << endl;
}
- for (RegexVector::ConstReverseIterator i (backup.rbegin ());
+ for (RegexVector::const_reverse_iterator i (backup.rbegin ());
i != backup.rend (); ++i)
{
if (trace)
- os << "try: '" << i->pattern () << "' : ";
+ os << "try: '" << i->regex () << "' : ";
if (i->match (s))
{
- String r (i->merge (s));
+ String r (i->replace (s));
if (trace)
os << "'" << r << "' : +" << endl;
@@ -474,11 +493,11 @@ namespace CXX
String
find_name (String const& base_name,
NameSet& set,
- Boolean insert = true)
+ bool insert = true)
{
String name (base_name);
- for (UnsignedLong i (1); set.find (name) != set.end (); ++i)
+ for (size_t i (1); set.find (name) != set.end (); ++i)
{
std::wostringstream os;
os << i;
@@ -492,23 +511,22 @@ namespace CXX
}
private:
- Void
- compile_regex (Containers::Vector<NarrowString> const& sv,
+ void
+ compile_regex (NarrowStrings const& sv,
RegexVector& rv,
String const& id)
{
- typedef Containers::Vector<NarrowString> Vector;
-
- for (Vector::ConstIterator i (sv.begin ()); i != sv.end (); ++i)
+ for (NarrowStrings::const_iterator i (sv.begin ()); i != sv.end ();
+ ++i)
{
try
{
- rv.push_back (Regex (*i));
+ rv.push_back (*i);
}
catch (RegexFormat const& e)
{
os << "error: invalid " << id << " name regex: '" <<
- e.expression () << "': " << e.description () << endl;
+ e.regex () << "': " << e.description ().c_str () << endl;
throw Failed ();
}
@@ -516,8 +534,8 @@ namespace CXX
}
private:
- Cult::Containers::Map<String, NameSet> global_type_names_;
- Cult::Containers::Map<String, NameSet> global_element_names_;
+ map<String, NameSet> global_type_names_;
+ map<String, NameSet> global_element_names_;
RegexVector type_regex_;
RegexVector accessor_regex_;
@@ -530,14 +548,15 @@ namespace CXX
RegexVector seq_modifier_regex_;
RegexVector parser_regex_;
RegexVector serializer_regex_;
+ RegexVector const_regex_;
RegexVector enumerator_regex_;
RegexVector element_type_regex_;
public:
- Cult::Containers::Map<String, NameSet>& global_type_names;
- Cult::Containers::Map<String, NameSet>& global_element_names;
+ map<String, NameSet>& global_type_names;
+ map<String, NameSet>& global_element_names;
- Boolean detach;
+ bool detach;
RegexVector& type_regex;
RegexVector& accessor_regex;
@@ -550,6 +569,7 @@ namespace CXX
RegexVector& seq_modifier_regex;
RegexVector& parser_regex;
RegexVector& serializer_regex;
+ RegexVector& const_regex;
RegexVector& enumerator_regex;
RegexVector& element_type_regex;
};
@@ -563,7 +583,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& e)
{
// Process the name with enumerator name regex.
@@ -590,7 +610,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& e)
{
// Use processed name.
@@ -630,7 +650,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& m)
{
if (Tree::Context::skip (m))
@@ -657,20 +677,23 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& m)
{
if (Tree::Context::skip (m))
return;
- UnsignedLong max (Tree::Context::max (m));
- UnsignedLong min (Tree::Context::min (m));
+ SemanticGraph::Complex& c (
+ dynamic_cast<SemanticGraph::Complex&> (m.scope ()));
+
+ size_t max (Tree::Context::max (m));
+ size_t min (Tree::Context::min (m));
String const& s (m.context ().get<String> ("stem"));
String const& b (m.context ().get<String> ("name"));
- Boolean def_attr (m.default_p () &&
- m.is_a<SemanticGraph::Attribute> ());
+ bool def_attr (m.default_p () &&
+ m.is_a<SemanticGraph::Attribute> ());
// Accessors/modifiers. Note that we postpone inserting
// the names into the name_set to avoid over-escaping.
@@ -809,7 +832,7 @@ namespace CXX
//
if (m.default_p ())
{
- Boolean simple (true);
+ bool simple (true);
if (m.is_a<SemanticGraph::Element> ())
{
@@ -824,9 +847,9 @@ namespace CXX
process_regex (
s + L",default,value", accessor_regex, L"accessor")));
- m.context ().set ( "default-value", find_name (an, name_set_));
+ m.context ().set ("default-value", find_name (an, name_set_));
- Boolean lit (false);
+ bool lit (false);
{
IsLiteralValue test (lit);
test.dispatch (m.type ());
@@ -840,6 +863,18 @@ namespace CXX
}
}
}
+
+ // Element id.
+ //
+ if (m.is_a<SemanticGraph::Element> () && ordered_p (c))
+ {
+ String id (
+ escape (
+ process_regex (
+ s + L",id", const_regex, L"const")));
+
+ m.context ().set ("ordered-id-name", find_name (id, name_set_));
+ }
}
private:
@@ -854,7 +889,7 @@ namespace CXX
Any (Context& c,
NameSet& name_set,
NameSet& stem_set,
- Boolean& has_wildcard)
+ bool& has_wildcard)
: Context (c),
name_set_ (name_set),
stem_set_ (stem_set),
@@ -862,11 +897,14 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Any& a)
{
- UnsignedLong max (Tree::Context::max (a));
- UnsignedLong min (Tree::Context::min (a));
+ SemanticGraph::Complex& c (
+ dynamic_cast<SemanticGraph::Complex&> (a.scope ()));
+
+ size_t max (Tree::Context::max (a));
+ size_t min (Tree::Context::min (a));
String s (find_name (L"any", stem_set_));
@@ -980,11 +1018,23 @@ namespace CXX
//
a.context ().set ("member", find_name (b + L"_", name_set_));
+ // Wildcard id.
+ //
+ if (ordered_p (c))
+ {
+ String id (
+ escape (
+ process_regex (
+ s + L",id", const_regex, L"const")));
+
+ a.context ().set ("ordered-id-name", find_name (id, name_set_));
+ }
+
if (!has_wildcard_)
has_wildcard_ = true;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::AnyAttribute& a)
{
String s (find_name (L"any,attribute", stem_set_));
@@ -1050,7 +1100,7 @@ namespace CXX
private:
NameSet& name_set_;
NameSet& stem_set_;
- Boolean& has_wildcard_;
+ bool& has_wildcard_;
};
//
@@ -1062,20 +1112,20 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& c)
{
- SemanticGraph::Context& cc (c.context ());
+ SemanticGraph::Context& ctx (c.context ());
// We leave this set around to allow other mappings to use
// this information.
//
- cc.set ("cxx-tree-name-processor-stem-set", NameSet ());
- cc.set ("cxx-tree-name-processor-member-set", NameSet ());
+ ctx.set ("cxx-tree-name-processor-stem-set", NameSet ());
+ ctx.set ("cxx-tree-name-processor-member-set", NameSet ());
// Use processed name.
//
- String name (cc.get<String> ("name"));
+ String name (ctx.get<String> ("name"));
// If renamed name is empty then we are not generating
// anything for this type and name processing is not
@@ -1085,10 +1135,10 @@ namespace CXX
return;
NameSet& stem_set (
- cc.get<NameSet> ("cxx-tree-name-processor-stem-set"));
+ ctx.get<NameSet> ("cxx-tree-name-processor-stem-set"));
NameSet& member_set (
- cc.get<NameSet> ("cxx-tree-name-processor-member-set"));
+ ctx.get<NameSet> ("cxx-tree-name-processor-member-set"));
stem_set.insert (c.name ());
member_set.insert (name);
@@ -1144,11 +1194,121 @@ namespace CXX
Complex::names (c, names);
}
+ // Names for the mixed content.
+ //
+ if (mixed_p (c))
+ {
+ // Check if we already have the mixed content down inheritance
+ // hierarchy.
+ //
+ using SemanticGraph::Complex;
+
+ for (Complex* p (&c); p->inherits_p ();)
+ {
+ if (Complex* b = dynamic_cast<Complex*> (
+ &p->inherits ().base ()))
+ {
+ if (mixed_p (*b))
+ {
+ SemanticGraph::Context& bctx (b->context ());
+ ctx.set ("mixed-type", bctx.get<String> ("mixed-type"));
+ ctx.set ("mixed-const-iterator",
+ bctx.get<String> ("mixed-const-iterator"));
+ ctx.set ("mixed-ordered-id-name",
+ bctx.get<String> ("mixed-ordered-id-name"));
+ ctx.set ("mixed-aname", bctx.get<String> ("mixed-aname"));
+ ctx.set ("mixed-member", bctx.get<String> ("mixed-member"));
+ ctx.set ("mixed-in-base", true);
+ break;
+ }
+
+ p = b;
+ }
+ else
+ break;
+ }
+
+ // If not, set up the names.
+ //
+ if (!ctx.count ("mixed-in-base"))
+ {
+ String s (find_name (L"text,content", stem_set));
+ String n (find_name (escape (s), member_set, false));
+
+ String an (find_name (
+ escape (process_regex (s,
+ seq_accessor_regex,
+ accessor_regex,
+ L"sequence accessor")),
+ member_set,
+ false));
+
+ String mn (find_name (
+ escape (process_regex (s,
+ seq_modifier_regex,
+ modifier_regex,
+ L"sequence modifier")),
+ member_set,
+ false));
+
+ ctx.set ("mixed-aname", an);
+ ctx.set ("mixed-mname", mn);
+
+ member_set.insert (name);
+
+ if (an != n)
+ member_set.insert (an);
+
+ if (mn != n && mn != an)
+ member_set.insert (mn);
+
+ // Types.
+ //
+ ctx.set (
+ "mixed-type",
+ find_name (
+ escape (process_regex (s + L",type", type_regex, L"type")),
+ member_set));
+
+ ctx.set (
+ "mixed-container",
+ find_name (
+ escape (process_regex (s + L",sequence", type_regex, L"type")),
+ member_set));
+
+ ctx.set (
+ "mixed-iterator",
+ find_name (
+ escape (process_regex (s + L",iterator", type_regex, L"type")),
+ member_set));
+
+ ctx.set (
+ "mixed-const-iterator",
+ find_name (
+ escape (
+ process_regex (s + L",const,iterator", type_regex, L"type")),
+ member_set));
+
+ // Text content id.
+ //
+ ctx.set (
+ "mixed-ordered-id-name",
+ find_name (
+ escape (
+ process_regex (s + L",id", const_regex, L"const")),
+ member_set));
+
+ // Data member.
+ //
+ ctx.set ("mixed-member", find_name (n + L"_", member_set));
+ }
+ }
+
// Names for wildcards.
//
- if (options.value<CLI::generate_wildcard> ())
+ if (options.generate_wildcard ())
{
- Boolean has_wildcard (false);
+ bool has_wildcard (false);
Any any (*this, member_set, stem_set, has_wildcard);
Traversal::Names names (any);
Complex::names (c, names);
@@ -1198,6 +1358,105 @@ namespace CXX
}
}
}
+
+ // Names for the order container.
+ //
+ if (ordered_p (c))
+ {
+ // Check if we already have the order container down
+ // inheritance hierarchy.
+ //
+ using SemanticGraph::Complex;
+
+ for (Complex* p (&c); p->inherits_p ();)
+ {
+ if (Complex* b = dynamic_cast<Complex*> (
+ &p->inherits ().base ()))
+ {
+ if (ordered_p (*b))
+ {
+ SemanticGraph::Context& bctx (b->context ());
+ ctx.set ("order-type", bctx.get<String> ("order-type"));
+ ctx.set ("order-const-iterator",
+ bctx.get<String> ("order-const-iterator"));
+ ctx.set ("order-aname", bctx.get<String> ("order-aname"));
+ ctx.set ("order-member", bctx.get<String> ("order-member"));
+ ctx.set ("order-in-base", true);
+ break;
+ }
+
+ p = b;
+ }
+ else
+ break;
+ }
+
+ // If not, set up the names.
+ //
+ if (!ctx.count ("order-in-base"))
+ {
+ String s (find_name (L"content,order", stem_set));
+ String n (find_name (escape (s), member_set, false));
+
+ String an (find_name (
+ escape (process_regex (s,
+ seq_accessor_regex,
+ accessor_regex,
+ L"sequence accessor")),
+ member_set,
+ false));
+
+ String mn (find_name (
+ escape (process_regex (s,
+ seq_modifier_regex,
+ modifier_regex,
+ L"sequence modifier")),
+ member_set,
+ false));
+
+ ctx.set ("order-aname", an);
+ ctx.set ("order-mname", mn);
+
+ member_set.insert (name);
+
+ if (an != n)
+ member_set.insert (an);
+
+ if (mn != n && mn != an)
+ member_set.insert (mn);
+
+ // Types.
+ //
+ ctx.set (
+ "order-type",
+ find_name (
+ escape (process_regex (s + L",type", type_regex, L"type")),
+ member_set));
+
+ ctx.set (
+ "order-container",
+ find_name (
+ escape (process_regex (s + L",sequence", type_regex, L"type")),
+ member_set));
+
+ ctx.set (
+ "order-iterator",
+ find_name (
+ escape (process_regex (s + L",iterator", type_regex, L"type")),
+ member_set));
+
+ ctx.set (
+ "order-const-iterator",
+ find_name (
+ escape (
+ process_regex (s + L",const,iterator", type_regex, L"type")),
+ member_set));
+
+ // Data member.
+ //
+ ctx.set ("order-member", find_name (n + L"_", member_set));
+ }
+ }
}
};
@@ -1211,7 +1470,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Type& t)
{
// Process the name with type name regex.
@@ -1254,7 +1513,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& e)
{
// First we need to figure out if we need to process this
@@ -1263,7 +1522,7 @@ namespace CXX
if (!generate_p (e))
return;
- if (options.value<CLI::generate_element_type> ())
+ if (options.generate_element_type ())
{
SemanticGraph::Context& ec (e.context ());
@@ -1379,7 +1638,7 @@ namespace CXX
//
String p;
- if (!options.value<CLI::suppress_parsing> () && doc_root_p (e))
+ if (!options.suppress_parsing () && doc_root_p (e))
{
p = find_name (
escape (
@@ -1392,8 +1651,7 @@ namespace CXX
//
String s;
- if (options.value<CLI::generate_serialization> () &&
- doc_root_p (e))
+ if (options.generate_serialization () && doc_root_p (e))
{
s = find_name (
escape (
@@ -1430,7 +1688,7 @@ namespace CXX
if (type_set_.find (r) != type_set_.end ())
r += L"_";
- for (UnsignedLong i (1);
+ for (size_t i (1);
element_set_.find (r) != element_set_.end () ||
type_set_.find (r) != type_set_.end (); ++i)
{
@@ -1454,7 +1712,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& ns)
{
NameSet& type_set (global_type_names[ns.name ()]);
@@ -1475,7 +1733,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& ns)
{
String const& name (ns.name ());
@@ -1557,7 +1815,7 @@ namespace CXX
*this >> names_ >> *this;
}
- Void
+ void
process_name (SemanticGraph::Type& t, String const& name)
{
String r (
@@ -1567,10 +1825,10 @@ namespace CXX
t.context ().set ("name", escape (r));
}
- Void
+ void
process_name (SemanticGraph::Namespace& n,
String const& name,
- Char const* key)
+ char const* key)
{
String r (process_regex (name, type_regex, L"type"));
n.context ().set (key, escape (r));
@@ -1578,13 +1836,13 @@ namespace CXX
// anyType and anySimpleType
//
- virtual Void
+ virtual void
traverse (SemanticGraph::AnyType& t)
{
process_name (t, "type");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::AnySimpleType& t)
{
process_name (t, "simple,type");
@@ -1592,79 +1850,79 @@ namespace CXX
// Integrals.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Byte& t)
{
process_name (t, "byte");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::UnsignedByte& t)
{
process_name (t, "unsigned,byte");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Short& t)
{
process_name (t, "short");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::UnsignedShort& t)
{
process_name (t, "unsigned,short");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Int& t)
{
process_name (t, "int");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::UnsignedInt& t)
{
process_name (t, "unsigned,int");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Long& t)
{
process_name (t, "long");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::UnsignedLong& t)
{
process_name (t, "unsigned,long");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Integer& t)
{
process_name (t, "integer");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NonPositiveInteger& t)
{
process_name (t, "non,positive,integer");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NonNegativeInteger& t)
{
process_name (t, "non,negative,integer");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::PositiveInteger& t)
{
process_name (t, "positive,integer");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NegativeInteger& t)
{
process_name (t, "negative,integer");
@@ -1672,7 +1930,7 @@ namespace CXX
// Boolean.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Boolean& t)
{
process_name (t, "boolean");
@@ -1680,19 +1938,19 @@ namespace CXX
// Floats.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Float& t)
{
process_name (t, "float");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Double& t)
{
process_name (t, "double");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Decimal& t)
{
process_name (t, "decimal");
@@ -1700,49 +1958,49 @@ namespace CXX
// Strings.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::String& t)
{
process_name (t, "string");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NormalizedString& t)
{
process_name (t, "normalized,string");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Token& t)
{
process_name (t, "token");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NameToken& t)
{
process_name (t, "nmtoken");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NameTokens& t)
{
process_name (t, "nmtokens");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Name& t)
{
process_name (t, "name");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NCName& t)
{
process_name (t, "ncname");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Language& t)
{
process_name (t, "language");
@@ -1750,19 +2008,19 @@ namespace CXX
// ID/IDREF.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Id& t)
{
process_name (t, "id");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::IdRef& t)
{
process_name (t, "idref");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::IdRefs& t)
{
process_name (t, "idrefs");
@@ -1771,7 +2029,7 @@ namespace CXX
// URI.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::AnyURI& t)
{
process_name (t, "uri");
@@ -1779,7 +2037,7 @@ namespace CXX
// Qualified name.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::QName& t)
{
process_name (t, "qname");
@@ -1787,13 +2045,13 @@ namespace CXX
// Binary.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Base64Binary& t)
{
process_name (t, "base64,binary");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::HexBinary& t)
{
process_name (t, "hex,binary");
@@ -1802,55 +2060,55 @@ namespace CXX
// Date/time.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Date& t)
{
process_name (t, "date");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::DateTime& t)
{
process_name (t, "date,time");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Duration& t)
{
process_name (t, "duration");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Day& t)
{
process_name (t, "gday");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Month& t)
{
process_name (t, "gmonth");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::MonthDay& t)
{
process_name (t, "gmonth,day");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Year& t)
{
process_name (t, "gyear");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::YearMonth& t)
{
process_name (t, "gyear,month");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Time& t)
{
process_name (t, "time");
@@ -1858,19 +2116,19 @@ namespace CXX
// Entity.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Entity& t)
{
process_name (t, "entity");
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Entities& t)
{
process_name (t, "entities");
}
- virtual Void
+ virtual void
post (SemanticGraph::Namespace& n)
{
// Assign names to extra stuff in the XML Schema namespace.
@@ -1879,13 +2137,15 @@ namespace CXX
process_name (n, "buffer", "buffer");
process_name (n, "time,zone", "time-zone");
- if (options.value<CLI::generate_element_type> ())
+ process_name (n, "content,order", "content-order");
+
+ if (options.generate_element_type ())
process_name (n, "element,type", "element-type");
- if (options.value<CLI::generate_element_map> ())
+ if (options.generate_element_map ())
process_name (n, "element,map", "element-map");
- if (options.value<CLI::generate_serialization> ())
+ if (options.generate_serialization ())
{
process_name (n, "namespace,info", "namespace-info");
process_name (n, "namespace,infomap", "namespace-infomap");
@@ -1895,12 +2155,12 @@ namespace CXX
process_name (n, "facet", "facet");
}
- if (!options.value<CLI::generate_insertion> ().empty ())
+ if (!options.generate_insertion ().empty ())
{
process_name (n, "ostream", "ostream");
}
- if (!options.value<CLI::generate_extraction> ().empty ())
+ if (!options.generate_extraction ().empty ())
{
process_name (n, "istream", "istream");
}
@@ -1908,7 +2168,7 @@ namespace CXX
process_name (n, "flags", "flags");
process_name (n, "properties", "properties");
- NarrowString fn (options.value<CLI::function_naming> ());
+ NarrowString fn (options.function_naming ());
if (fn == "knr")
n.context ().set ("tree-node-key", String ("tree_node_key"));
@@ -1936,8 +2196,8 @@ namespace CXX
process_name (n, "error", "error");
process_name (n, "diagnostics", "diagnostics");
- if (!options.value<CLI::suppress_parsing> () ||
- options.value<CLI::generate_serialization> ())
+ if (!options.suppress_parsing () ||
+ options.generate_serialization ())
{
process_name (n, "error,handler", "error-handler");
}
@@ -1955,7 +2215,7 @@ namespace CXX
//
struct UsesPassOne: Traversal::Uses
{
- virtual Void
+ virtual void
traverse (Type& u)
{
SemanticGraph::Schema& s (u.schema ());
@@ -1970,7 +2230,7 @@ namespace CXX
struct UsesPassThree: Traversal::Uses
{
- virtual Void
+ virtual void
traverse (Type& u)
{
SemanticGraph::Schema& s (u.schema ());
@@ -1988,7 +2248,7 @@ namespace CXX
//
struct Implies: Traversal::Implies
{
- virtual Void
+ virtual void
traverse (SemanticGraph::Implies& i)
{
SemanticGraph::Schema& s (i.schema ());
@@ -2001,8 +2261,8 @@ namespace CXX
}
};
- Boolean
- process_impl (CLI::Options const& ops,
+ bool
+ process_impl (options const& ops,
SemanticGraph::Schema& tu,
SemanticGraph::Path const& file,
StringLiteralMap const& map)
@@ -2064,7 +2324,7 @@ namespace CXX
//
{
Traversal::Schema schema;
- Traversal::Sources sources;
+ Sources sources;
schema >> sources >> schema;
@@ -2128,8 +2388,8 @@ namespace CXX
}
}
- Boolean NameProcessor::
- process (CLI::Options const& ops,
+ bool NameProcessor::
+ process (options const& ops,
SemanticGraph::Schema& tu,
SemanticGraph::Path const& file,
StringLiteralMap const& map)
diff --git a/xsd/xsd/cxx/tree/name-processor.hxx b/xsd/xsd/cxx/tree/name-processor.hxx
index cf187b7..46ea883 100644
--- a/xsd/xsd/cxx/tree/name-processor.hxx
+++ b/xsd/xsd/cxx/tree/name-processor.hxx
@@ -1,26 +1,24 @@
// file : xsd/cxx/tree/name-processor.hxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2006-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2006-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#ifndef CXX_TREE_NAME_PROCESSOR_HXX
#define CXX_TREE_NAME_PROCESSOR_HXX
+#include <types.hxx>
+
#include <cxx/tree/elements.hxx>
+#include <cxx/tree/options.hxx>
namespace CXX
{
namespace Tree
{
- using namespace Cult::Types;
-
class NameProcessor
{
public:
- NameProcessor (); // Dummy ctor, helps with long symbols on HP-UX.
-
- Boolean
- process (CLI::Options const&,
+ bool
+ process (options const&,
XSDFrontend::SemanticGraph::Schema&,
XSDFrontend::SemanticGraph::Path const& file,
StringLiteralMap const&);
diff --git a/xsd/xsd/cxx/tree/options.cli b/xsd/xsd/cxx/tree/options.cli
new file mode 100644
index 0000000..f1b343a
--- /dev/null
+++ b/xsd/xsd/cxx/tree/options.cli
@@ -0,0 +1,480 @@
+// file : xsd/cxx/tree/options.cli
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+include <cstddef>; // std::size_t
+
+include <types.hxx>; // NarrowString, NarrowStrings
+
+include <cxx/options.cli>;
+
+namespace CXX
+{
+ namespace Tree
+ {
+ class options: CXX::options
+ {
+ // Polymorphism.
+ //
+ bool --generate-polymorphic
+ {
+ "Generate polymorphism-aware code. Specify this option if you use
+ substitution groups or \cb{xsi:type}. Use the \cb{--polymorphic-type}
+ or \cb{--polymorphic-type-all} option to specify which type
+ hierarchies are polymorphic."
+ };
+
+ NarrowStrings --polymorphic-type
+ {
+ "<type>",
+ "Indicate that <type> is a root of a polymorphic type hierarchy. The
+ compiler can often automatically determine which types are
+ polymorphic based on the substitution group declarations. However,
+ you may need to use this option if you are not using substitution
+ groups or if substitution groups are defined in another schema. You
+ need to specify this option when compiling every schema file that
+ references <type>. The <type> argument is an XML Schema type name
+ that can be optionally qualified with a namespace in the
+ \c{\i{namespace}\b{#}\i{name}} form."
+ };
+
+ bool --polymorphic-type-all
+ {
+ "Indicate that all types should be treated as polymorphic."
+ };
+
+ unsigned long --polymorphic-plate = 0
+ {
+ "<num>",
+ "Specify the polymorphic map plate the generated code should register
+ on. This functionality is primarily useful to segregate multiple
+ schemas that define the same polymorphic types."
+ };
+
+ // Ordered content.
+ //
+ NarrowStrings --ordered-type
+ {
+ "<type>",
+ "Indicate that element order in <type> is significant. An example
+ would be a complex type with unbounded choice as a content model
+ where the element order in XML has application-specific semantics.
+ For ordered types the compiler generates a special container data
+ member and a corresponding set of accessors and modifiers that are
+ used to capture the order of elements and, for mixed content, of
+ text.
+
+ The <type> argument is an XML Schema type name that can be optionally
+ qualified with a namespace in the \c{\i{namespace}\b{#}\i{name}} form.
+ Note also that you will need to specify this option when compiling
+ every schema file that has other ordered types derived from this
+ type."
+ };
+
+ bool --ordered-type-derived
+ {
+ "Automatically treat types derived from ordered bases as also
+ ordered. This is primarily useful if you would like to be able
+ to iterate over the complete content using the content order
+ container."
+ };
+
+ bool --ordered-type-mixed
+ {
+ "Automatically treat complex types with mixed content as ordered."
+ };
+
+ bool --ordered-type-all
+ {
+ "Indicate that element order in all types is significant."
+ };
+
+ NarrowString --order-container
+ {
+ "<type>",
+ "Specify a custom class template that should be used as a container
+ for the content order in ordered types instead of the default
+ \cb{std::vector}. See \cb{--ordered-type} for more information on
+ ordered type. This option is primarily useful if you need to
+ perform more complex lookups in the content order container, for
+ example by element id. In this case, a container like Boost
+ multi-index may be more convenient. Note that if using a custom
+ container, you will also most likely need to include the relevant
+ headers using the \cb{--hxx-prologue*} options."
+ };
+
+ // Features.
+ //
+ bool --generate-serialization
+ {
+ "Generate serialization functions. Serialization functions convert
+ the object model back to XML."
+ };
+
+ bool --generate-ostream
+ {
+ "Generate ostream insertion operators (\cb{operator<<}) for generated
+ types. This allows one to easily print a fragment or the whole object
+ model for debugging or logging."
+ };
+
+ bool --generate-doxygen
+ {
+ "Generate documentation comments suitable for extraction by the
+ Doxygen documentation system. Documentation from annotations is
+ added to the comments if present in the schema."
+ };
+
+ bool --generate-comparison
+ {
+ "Generate comparison operators (\cb{operator==} and \cb{operator!=})
+ for complex types. Comparison is performed member-wise."
+ };
+
+ bool --generate-default-ctor
+ {
+ "Generate default constructors even for types that have required
+ members. Required members of an instance constructed using such a
+ constructor are not initialized and accessing them results in
+ undefined behavior."
+ };
+
+ bool --generate-from-base-ctor
+ {
+ "Generate constructors that expect an instance of a base type
+ followed by all required members."
+ };
+
+ bool --suppress-assignment
+ {
+ "Suppress the generation of copy assignment operators for complex
+ types. If this option is specified, the copy assignment operators
+ for such types are declared private and left unimplemented."
+ };
+
+ bool --generate-detach
+ {
+ "Generate detach functions for required elements and attributes.
+ Detach functions for optional and sequence cardinalities are
+ provided by the respective containers. These functions, for
+ example, allow you to move sub-trees in the object model either
+ within the same tree or between different trees."
+ };
+
+ bool --generate-wildcard
+ {
+ "Generate accessors and modifiers as well as parsing and serialization
+ code for XML Schema wildcards (\cb{any} and \cb{anyAttribute}). XML
+ content matched by wildcards is presented as DOM fragments. Note
+ that you need to initialize the Xerces-C++ runtime if you are using
+ 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>",
+ "Generate data representation stream insertion operators for the <os>
+ output stream type. Repeat this option to specify more than one
+ stream type. The ACE CDR stream (\cb{ACE_OutputCDR}) and RPC XDR
+ are recognized by the compiler and the necessary \cb{#include}
+ directives are automatically generated. For custom stream types use
+ the \cb{--hxx-prologue*} options to provide the necessary
+ declarations."
+ };
+
+ NarrowStrings --generate-extraction
+ {
+ "<is>",
+ "Generate data representation stream extraction constructors for the
+ <is> input stream type. Repeat this option to specify more than one
+ stream type. The ACE CDR stream (\cb{ACE_InputCDR}) and RPC XDR are
+ recognized by the compiler and the necessary \cb{#include} directives
+ are automatically generated. For custom stream types use the
+ \cb{--hxx-prologue*} options to provide the necessary declarations."
+ };
+
+ bool --generate-forward
+ {
+ "Generate a separate header file with forward declarations for the
+ types being generated."
+ };
+
+ bool --suppress-parsing
+ {
+ "Suppress the generation of the parsing functions and constructors.
+ Use this option to reduce the generated code size when parsing from
+ XML is not needed."
+ };
+
+ bool --generate-element-type
+ {
+ "Generate types instead of parsing and serialization functions for
+ root elements. This is primarily useful to distinguish object models
+ with the same root type but with different root elements."
+ };
+
+ bool --generate-element-map
+ {
+ "Generate a root element map that allows uniform parsing and
+ serialization of multiple root elements. This option is only valid
+ together with \cb{--generate-element-type}."
+ };
+
+ bool --generate-intellisense
+ {
+ "Generate workarounds for IntelliSense bugs in Visual Studio 2005
+ (8.0). When this option is used, the resulting code is slightly
+ more verbose. IntelliSense in Visual Studio 2008 (9.0) and later
+ does not require these workarounds. Support for IntelliSense in
+ Visual Studio 2003 (7.1) is improved with this option but is
+ still incomplete."
+ };
+
+ bool --omit-default-attributes
+ {
+ "Omit attributes with default and fixed values from serialized XML
+ documents."
+ };
+
+ // Naming.
+ //
+ NarrowString --type-naming = "knr"
+ {
+ "<style>",
+ "Specify the type naming convention that should be used in the
+ generated code. Valid styles are \cb{knr} (default), \cb{ucc},
+ and \cb{java}. See the NAMING CONVENTION section below for more
+ information."
+ };
+
+ NarrowString --function-naming = "knr"
+ {
+ "<style>",
+ "Specify the function naming convention that should be used in the
+ generated code. Valid styles are \cb{knr} (default), \cb{lcc}, and
+ \cb{java}. See the NAMING CONVENTION section below for more
+ information."
+ };
+
+ NarrowStrings --type-regex
+ {
+ "<regex>",
+ "Add <regex> to the list of regular expressions used to translate
+ XML Schema type names to C++ type names. See the NAMING CONVENTION
+ section below for more information."
+ };
+
+ NarrowStrings --accessor-regex
+ {
+ "<regex>",
+ "Add <regex> to the list of regular expressions used to translate
+ XML Schema names of elements/attributes to C++ accessor function
+ names. See the NAMING CONVENTION section below for more information."
+ };
+
+ NarrowStrings --one-accessor-regex
+ {
+ "<regex>",
+ "Add <regex> to the list of regular expressions used to translate
+ XML Schema names of elements/attributes with cardinality one to
+ C++ accessor function names. See the NAMING CONVENTION section
+ below for more information."
+ };
+
+ NarrowStrings --opt-accessor-regex
+ {
+ "<regex>",
+ "Add <regex> to the list of regular expressions used to translate
+ XML Schema names of elements/attributes with cardinality optional
+ to C++ accessor function names. See the NAMING CONVENTION section
+ below for more information."
+ };
+
+ NarrowStrings --seq-accessor-regex
+ {
+ "<regex>",
+ "Add <regex> to the list of regular expressions used to translate
+ XML Schema names of elements/attributes with cardinality sequence
+ to C++ accessor function names. See the NAMING CONVENTION section
+ below for more information."
+ };
+
+ NarrowStrings --modifier-regex
+ {
+ "<regex>",
+ "Add <regex> to the list of regular expressions used to translate
+ XML Schema names of elements/attributes to C++ modifier function
+ names. See the NAMING CONVENTION section below for more information."
+ };
+
+ NarrowStrings --one-modifier-regex
+
+ {
+ "<regex>",
+ "Add <regex> to the list of regular expressions used to translate
+ XML Schema names of elements/attributes with cardinality one to C++
+ modifier function names. See the NAMING CONVENTION section below
+ for more information."
+ };
+
+ NarrowStrings --opt-modifier-regex
+ {
+ "<regex>",
+ "Add <regex> to the list of regular expressions used to translate
+ XML Schema names of elements/attributes with cardinality optional
+ to C++ modifier function names. See the NAMING CONVENTION section
+ below for more information."
+ };
+
+ NarrowStrings --seq-modifier-regex
+ {
+ "<regex>",
+ "Add <regex> to the list of regular expressions used to translate
+ XML Schema names of elements/attributes with cardinality sequence
+ to C++ modifier function names. See the NAMING CONVENTION section
+ below for more information."
+ };
+
+ NarrowStrings --parser-regex
+ {
+ "<regex>",
+ "Add <regex> to the list of regular expressions used to translate
+ XML Schema element names to C++ parsing function names. See the
+ NAMING CONVENTION section below for more information."
+ };
+
+ NarrowStrings --serializer-regex
+ {
+ "<regex>",
+ "Add <regex> to the list of regular expressions used to translate
+ XML Schema element names to C++ serialization function names. See
+ the NAMING CONVENTION section below for more information."
+ };
+
+ NarrowStrings --const-regex
+ {
+ "<regex>",
+ "Add <regex> to the list of regular expressions used to translate
+ XML Schema-derived names to C++ constant names. See the NAMING
+ CONVENTION section below for more information."
+ };
+
+ NarrowStrings --enumerator-regex
+ {
+ "<regex>",
+ "Add <regex> to the list of regular expressions used to translate
+ XML Schema enumeration values to C++ enumerator names. See the
+ NAMING CONVENTION section below for more information."
+ };
+
+ NarrowStrings --element-type-regex
+ {
+ "<regex>",
+ "Add <regex> to the list of regular expressions used to translate
+ XML Schema element names to C++ element type names. See the NAMING
+ CONVENTION section below for more information."
+ };
+
+ bool --name-regex-trace
+ {
+ "Trace the process of applying regular expressions specified with
+ the name transformation options. Use this option to find out why
+ your regular expressions don't do what you expected them to do."
+ };
+
+ // Root element.
+ //
+ bool --root-element-first
+ {
+ "Treat only the first global element as a document root. By default
+ all global elements are considered document roots."
+ };
+
+ bool --root-element-last
+ {
+ "Treat only the last global element as a document root. By default
+ all global elements are considered document roots."
+ };
+
+ bool --root-element-all
+ {
+ "Treat all global elements as document roots. This is the default
+ behavior. By explicitly specifying this option you can suppress
+ the warning that is issued if more than one global element is
+ defined."
+ };
+
+ bool --root-element-none
+ {
+ "Do not treat any global elements as document roots. By default all
+ global elements are considered document roots."
+ };
+
+ NarrowStrings --root-element
+ {
+ "<element>",
+ "Treat only <element> as a document root. Repeat this option to
+ specify more than one root element."
+ };
+
+ // Custom type.
+ //
+ NarrowStrings --custom-type
+ {
+ "<map>",
+ "Use a custom C++ type instead of the generated class. The <map>
+ argument is in the form \c{\i{name}[\b{=}\i{type}[\b{/}\i{base}]]},
+ where \i{name} is a type name as defined in XML Schema and \i{type}
+ is a C++ type name that should be used instead. If \i{type} is not
+ present or empty then the custom type is assumed to have the same
+ name and be defined in the same namespace as the generated class
+ would have. If \i{base} is specified then the generated class is
+ still generated but with that name."
+ };
+
+ NarrowStrings --custom-type-regex
+ {
+ "<regex>",
+ "Use custom C++ types instead of the generated classes. The <regex>
+ argument is in the form
+ \c{\b{/}\i{name-pat}\b{/}[\i{type-sub}\b{/}[\i{base-sub}\b{/}]]},
+ where \i{name-pat} is a regex pattern that will be matched against
+ type names as defined in XML Schema and \i{type-sub} is a C++ type
+ name substitution that should be used instead. If \i{type-sub} is
+ not present or its substitution results in an empty string then
+ the custom type is assumed to have the same name and be defined
+ in the same namespace as the generated class would have. If
+ \i{base-sub} is present and its substitution results in a
+ non-empty string then the generated class is still generated
+ but with the result of this substitution as its name. The pattern
+ and substitutions are in the Perl regular expression format.
+ See also the REGEX AND SHELL QUOTING section below."
+ };
+
+ // Parts.
+ //
+ std::size_t --parts = 1
+ {
+ "<num>",
+ "Split generated source code into <num> parts. This is useful when
+ translating large, monolithic schemas and a C++ compiler is not
+ able to compile the resulting source code at once (usually due
+ to insufficient memory)."
+ };
+
+ NarrowString --parts-suffix = "-"
+ {
+ "<suffix>",
+ "Use <suffix> instead of the default '\cb{-}' to separate the file
+ name from the part number."
+ };
+ };
+ }
+}
diff --git a/xsd/xsd/cxx/tree/options.cxx b/xsd/xsd/cxx/tree/options.cxx
new file mode 100644
index 0000000..820ebac
--- /dev/null
+++ b/xsd/xsd/cxx/tree/options.cxx
@@ -0,0 +1,1149 @@
+// This code was generated by CLI, a command line interface
+// compiler for C++.
+//
+
+// Begin prologue.
+//
+#include <options-parser.hxx>
+//
+// End prologue.
+
+#include <cxx/tree/options.hxx>
+
+#include <map>
+#include <set>
+#include <string>
+#include <vector>
+#include <ostream>
+#include <sstream>
+
+namespace cli
+{
+ template <typename X>
+ struct parser
+ {
+ static void
+ parse (X& x, bool& xs, scanner& s)
+ {
+ std::string o (s.next ());
+
+ if (s.more ())
+ {
+ std::string v (s.next ());
+ std::istringstream is (v);
+ if (!(is >> x && is.eof ()))
+ throw invalid_value (o, v);
+ }
+ else
+ throw missing_value (o);
+
+ xs = true;
+ }
+ };
+
+ template <>
+ struct parser<bool>
+ {
+ static void
+ parse (bool& x, scanner& s)
+ {
+ s.next ();
+ x = true;
+ }
+ };
+
+ template <>
+ struct parser<std::string>
+ {
+ static void
+ parse (std::string& x, bool& xs, scanner& s)
+ {
+ const char* o (s.next ());
+
+ if (s.more ())
+ x = s.next ();
+ else
+ throw missing_value (o);
+
+ xs = true;
+ }
+ };
+
+ template <typename X>
+ struct parser<std::vector<X> >
+ {
+ static void
+ parse (std::vector<X>& c, bool& xs, scanner& s)
+ {
+ X x;
+ bool dummy;
+ parser<X>::parse (x, dummy, s);
+ c.push_back (x);
+ xs = true;
+ }
+ };
+
+ template <typename X>
+ struct parser<std::set<X> >
+ {
+ static void
+ parse (std::set<X>& c, bool& xs, scanner& s)
+ {
+ X x;
+ bool dummy;
+ parser<X>::parse (x, dummy, s);
+ c.insert (x);
+ xs = true;
+ }
+ };
+
+ template <typename K, typename V>
+ struct parser<std::map<K, V> >
+ {
+ static void
+ parse (std::map<K, V>& m, bool& xs, scanner& s)
+ {
+ std::string o (s.next ());
+
+ if (s.more ())
+ {
+ std::string ov (s.next ());
+ std::string::size_type p = ov.find ('=');
+
+ if (p == std::string::npos)
+ {
+ K k = K ();
+
+ if (!ov.empty ())
+ {
+ std::istringstream ks (ov);
+
+ if (!(ks >> k && ks.eof ()))
+ throw invalid_value (o, ov);
+ }
+
+ m[k] = V ();
+ }
+ else
+ {
+ K k = K ();
+ V v = V ();
+ std::string kstr (ov, 0, p);
+ std::string vstr (ov, p + 1);
+
+ if (!kstr.empty ())
+ {
+ std::istringstream ks (kstr);
+
+ if (!(ks >> k && ks.eof ()))
+ throw invalid_value (o, ov);
+ }
+
+ if (!vstr.empty ())
+ {
+ std::istringstream vs (vstr);
+
+ if (!(vs >> v && vs.eof ()))
+ throw invalid_value (o, ov);
+ }
+
+ m[k] = v;
+ }
+ }
+ else
+ throw missing_value (o);
+
+ xs = true;
+ }
+ };
+
+ template <typename X, typename T, T X::*M>
+ void
+ thunk (X& x, scanner& s)
+ {
+ parser<T>::parse (x.*M, s);
+ }
+
+ template <typename X, typename T, T X::*M, bool X::*S>
+ void
+ thunk (X& x, scanner& s)
+ {
+ parser<T>::parse (x.*M, x.*S, s);
+ }
+}
+
+#include <map>
+#include <cstring>
+
+namespace CXX
+{
+ namespace Tree
+ {
+ // options
+ //
+
+ options::
+ options ()
+ : generate_polymorphic_ (),
+ polymorphic_type_ (),
+ polymorphic_type_specified_ (false),
+ polymorphic_type_all_ (),
+ polymorphic_plate_ (0),
+ polymorphic_plate_specified_ (false),
+ ordered_type_ (),
+ ordered_type_specified_ (false),
+ ordered_type_derived_ (),
+ ordered_type_mixed_ (),
+ ordered_type_all_ (),
+ order_container_ (),
+ order_container_specified_ (false),
+ generate_serialization_ (),
+ generate_ostream_ (),
+ generate_doxygen_ (),
+ generate_comparison_ (),
+ generate_default_ctor_ (),
+ generate_from_base_ctor_ (),
+ suppress_assignment_ (),
+ generate_detach_ (),
+ generate_wildcard_ (),
+ generate_any_type_ (),
+ generate_insertion_ (),
+ generate_insertion_specified_ (false),
+ generate_extraction_ (),
+ generate_extraction_specified_ (false),
+ generate_forward_ (),
+ suppress_parsing_ (),
+ generate_element_type_ (),
+ generate_element_map_ (),
+ generate_intellisense_ (),
+ omit_default_attributes_ (),
+ type_naming_ ("knr"),
+ type_naming_specified_ (false),
+ function_naming_ ("knr"),
+ function_naming_specified_ (false),
+ type_regex_ (),
+ type_regex_specified_ (false),
+ accessor_regex_ (),
+ accessor_regex_specified_ (false),
+ one_accessor_regex_ (),
+ one_accessor_regex_specified_ (false),
+ opt_accessor_regex_ (),
+ opt_accessor_regex_specified_ (false),
+ seq_accessor_regex_ (),
+ seq_accessor_regex_specified_ (false),
+ modifier_regex_ (),
+ modifier_regex_specified_ (false),
+ one_modifier_regex_ (),
+ one_modifier_regex_specified_ (false),
+ opt_modifier_regex_ (),
+ opt_modifier_regex_specified_ (false),
+ seq_modifier_regex_ (),
+ seq_modifier_regex_specified_ (false),
+ parser_regex_ (),
+ parser_regex_specified_ (false),
+ serializer_regex_ (),
+ serializer_regex_specified_ (false),
+ const_regex_ (),
+ const_regex_specified_ (false),
+ enumerator_regex_ (),
+ enumerator_regex_specified_ (false),
+ element_type_regex_ (),
+ element_type_regex_specified_ (false),
+ name_regex_trace_ (),
+ root_element_first_ (),
+ root_element_last_ (),
+ root_element_all_ (),
+ root_element_none_ (),
+ root_element_ (),
+ root_element_specified_ (false),
+ custom_type_ (),
+ custom_type_specified_ (false),
+ custom_type_regex_ (),
+ custom_type_regex_specified_ (false),
+ parts_ (1),
+ parts_specified_ (false),
+ parts_suffix_ ("-"),
+ parts_suffix_specified_ (false)
+ {
+ }
+
+ options::
+ options (int& argc,
+ char** argv,
+ bool erase,
+ ::cli::unknown_mode opt,
+ ::cli::unknown_mode arg)
+ : generate_polymorphic_ (),
+ polymorphic_type_ (),
+ polymorphic_type_specified_ (false),
+ polymorphic_type_all_ (),
+ polymorphic_plate_ (0),
+ polymorphic_plate_specified_ (false),
+ ordered_type_ (),
+ ordered_type_specified_ (false),
+ ordered_type_derived_ (),
+ ordered_type_mixed_ (),
+ ordered_type_all_ (),
+ order_container_ (),
+ order_container_specified_ (false),
+ generate_serialization_ (),
+ generate_ostream_ (),
+ generate_doxygen_ (),
+ generate_comparison_ (),
+ generate_default_ctor_ (),
+ generate_from_base_ctor_ (),
+ suppress_assignment_ (),
+ generate_detach_ (),
+ generate_wildcard_ (),
+ generate_any_type_ (),
+ generate_insertion_ (),
+ generate_insertion_specified_ (false),
+ generate_extraction_ (),
+ generate_extraction_specified_ (false),
+ generate_forward_ (),
+ suppress_parsing_ (),
+ generate_element_type_ (),
+ generate_element_map_ (),
+ generate_intellisense_ (),
+ omit_default_attributes_ (),
+ type_naming_ ("knr"),
+ type_naming_specified_ (false),
+ function_naming_ ("knr"),
+ function_naming_specified_ (false),
+ type_regex_ (),
+ type_regex_specified_ (false),
+ accessor_regex_ (),
+ accessor_regex_specified_ (false),
+ one_accessor_regex_ (),
+ one_accessor_regex_specified_ (false),
+ opt_accessor_regex_ (),
+ opt_accessor_regex_specified_ (false),
+ seq_accessor_regex_ (),
+ seq_accessor_regex_specified_ (false),
+ modifier_regex_ (),
+ modifier_regex_specified_ (false),
+ one_modifier_regex_ (),
+ one_modifier_regex_specified_ (false),
+ opt_modifier_regex_ (),
+ opt_modifier_regex_specified_ (false),
+ seq_modifier_regex_ (),
+ seq_modifier_regex_specified_ (false),
+ parser_regex_ (),
+ parser_regex_specified_ (false),
+ serializer_regex_ (),
+ serializer_regex_specified_ (false),
+ const_regex_ (),
+ const_regex_specified_ (false),
+ enumerator_regex_ (),
+ enumerator_regex_specified_ (false),
+ element_type_regex_ (),
+ element_type_regex_specified_ (false),
+ name_regex_trace_ (),
+ root_element_first_ (),
+ root_element_last_ (),
+ root_element_all_ (),
+ root_element_none_ (),
+ root_element_ (),
+ root_element_specified_ (false),
+ custom_type_ (),
+ custom_type_specified_ (false),
+ custom_type_regex_ (),
+ custom_type_regex_specified_ (false),
+ parts_ (1),
+ parts_specified_ (false),
+ parts_suffix_ ("-"),
+ parts_suffix_specified_ (false)
+ {
+ ::cli::argv_scanner s (argc, argv, erase);
+ _parse (s, opt, arg);
+ }
+
+ options::
+ options (int start,
+ int& argc,
+ char** argv,
+ bool erase,
+ ::cli::unknown_mode opt,
+ ::cli::unknown_mode arg)
+ : generate_polymorphic_ (),
+ polymorphic_type_ (),
+ polymorphic_type_specified_ (false),
+ polymorphic_type_all_ (),
+ polymorphic_plate_ (0),
+ polymorphic_plate_specified_ (false),
+ ordered_type_ (),
+ ordered_type_specified_ (false),
+ ordered_type_derived_ (),
+ ordered_type_mixed_ (),
+ ordered_type_all_ (),
+ order_container_ (),
+ order_container_specified_ (false),
+ generate_serialization_ (),
+ generate_ostream_ (),
+ generate_doxygen_ (),
+ generate_comparison_ (),
+ generate_default_ctor_ (),
+ generate_from_base_ctor_ (),
+ suppress_assignment_ (),
+ generate_detach_ (),
+ generate_wildcard_ (),
+ generate_any_type_ (),
+ generate_insertion_ (),
+ generate_insertion_specified_ (false),
+ generate_extraction_ (),
+ generate_extraction_specified_ (false),
+ generate_forward_ (),
+ suppress_parsing_ (),
+ generate_element_type_ (),
+ generate_element_map_ (),
+ generate_intellisense_ (),
+ omit_default_attributes_ (),
+ type_naming_ ("knr"),
+ type_naming_specified_ (false),
+ function_naming_ ("knr"),
+ function_naming_specified_ (false),
+ type_regex_ (),
+ type_regex_specified_ (false),
+ accessor_regex_ (),
+ accessor_regex_specified_ (false),
+ one_accessor_regex_ (),
+ one_accessor_regex_specified_ (false),
+ opt_accessor_regex_ (),
+ opt_accessor_regex_specified_ (false),
+ seq_accessor_regex_ (),
+ seq_accessor_regex_specified_ (false),
+ modifier_regex_ (),
+ modifier_regex_specified_ (false),
+ one_modifier_regex_ (),
+ one_modifier_regex_specified_ (false),
+ opt_modifier_regex_ (),
+ opt_modifier_regex_specified_ (false),
+ seq_modifier_regex_ (),
+ seq_modifier_regex_specified_ (false),
+ parser_regex_ (),
+ parser_regex_specified_ (false),
+ serializer_regex_ (),
+ serializer_regex_specified_ (false),
+ const_regex_ (),
+ const_regex_specified_ (false),
+ enumerator_regex_ (),
+ enumerator_regex_specified_ (false),
+ element_type_regex_ (),
+ element_type_regex_specified_ (false),
+ name_regex_trace_ (),
+ root_element_first_ (),
+ root_element_last_ (),
+ root_element_all_ (),
+ root_element_none_ (),
+ root_element_ (),
+ root_element_specified_ (false),
+ custom_type_ (),
+ custom_type_specified_ (false),
+ custom_type_regex_ (),
+ custom_type_regex_specified_ (false),
+ parts_ (1),
+ parts_specified_ (false),
+ parts_suffix_ ("-"),
+ parts_suffix_specified_ (false)
+ {
+ ::cli::argv_scanner s (start, argc, argv, erase);
+ _parse (s, opt, arg);
+ }
+
+ options::
+ options (int& argc,
+ char** argv,
+ int& end,
+ bool erase,
+ ::cli::unknown_mode opt,
+ ::cli::unknown_mode arg)
+ : generate_polymorphic_ (),
+ polymorphic_type_ (),
+ polymorphic_type_specified_ (false),
+ polymorphic_type_all_ (),
+ polymorphic_plate_ (0),
+ polymorphic_plate_specified_ (false),
+ ordered_type_ (),
+ ordered_type_specified_ (false),
+ ordered_type_derived_ (),
+ ordered_type_mixed_ (),
+ ordered_type_all_ (),
+ order_container_ (),
+ order_container_specified_ (false),
+ generate_serialization_ (),
+ generate_ostream_ (),
+ generate_doxygen_ (),
+ generate_comparison_ (),
+ generate_default_ctor_ (),
+ generate_from_base_ctor_ (),
+ suppress_assignment_ (),
+ generate_detach_ (),
+ generate_wildcard_ (),
+ generate_any_type_ (),
+ generate_insertion_ (),
+ generate_insertion_specified_ (false),
+ generate_extraction_ (),
+ generate_extraction_specified_ (false),
+ generate_forward_ (),
+ suppress_parsing_ (),
+ generate_element_type_ (),
+ generate_element_map_ (),
+ generate_intellisense_ (),
+ omit_default_attributes_ (),
+ type_naming_ ("knr"),
+ type_naming_specified_ (false),
+ function_naming_ ("knr"),
+ function_naming_specified_ (false),
+ type_regex_ (),
+ type_regex_specified_ (false),
+ accessor_regex_ (),
+ accessor_regex_specified_ (false),
+ one_accessor_regex_ (),
+ one_accessor_regex_specified_ (false),
+ opt_accessor_regex_ (),
+ opt_accessor_regex_specified_ (false),
+ seq_accessor_regex_ (),
+ seq_accessor_regex_specified_ (false),
+ modifier_regex_ (),
+ modifier_regex_specified_ (false),
+ one_modifier_regex_ (),
+ one_modifier_regex_specified_ (false),
+ opt_modifier_regex_ (),
+ opt_modifier_regex_specified_ (false),
+ seq_modifier_regex_ (),
+ seq_modifier_regex_specified_ (false),
+ parser_regex_ (),
+ parser_regex_specified_ (false),
+ serializer_regex_ (),
+ serializer_regex_specified_ (false),
+ const_regex_ (),
+ const_regex_specified_ (false),
+ enumerator_regex_ (),
+ enumerator_regex_specified_ (false),
+ element_type_regex_ (),
+ element_type_regex_specified_ (false),
+ name_regex_trace_ (),
+ root_element_first_ (),
+ root_element_last_ (),
+ root_element_all_ (),
+ root_element_none_ (),
+ root_element_ (),
+ root_element_specified_ (false),
+ custom_type_ (),
+ custom_type_specified_ (false),
+ custom_type_regex_ (),
+ custom_type_regex_specified_ (false),
+ parts_ (1),
+ parts_specified_ (false),
+ parts_suffix_ ("-"),
+ parts_suffix_specified_ (false)
+ {
+ ::cli::argv_scanner s (argc, argv, erase);
+ _parse (s, opt, arg);
+ end = s.end ();
+ }
+
+ options::
+ options (int start,
+ int& argc,
+ char** argv,
+ int& end,
+ bool erase,
+ ::cli::unknown_mode opt,
+ ::cli::unknown_mode arg)
+ : generate_polymorphic_ (),
+ polymorphic_type_ (),
+ polymorphic_type_specified_ (false),
+ polymorphic_type_all_ (),
+ polymorphic_plate_ (0),
+ polymorphic_plate_specified_ (false),
+ ordered_type_ (),
+ ordered_type_specified_ (false),
+ ordered_type_derived_ (),
+ ordered_type_mixed_ (),
+ ordered_type_all_ (),
+ order_container_ (),
+ order_container_specified_ (false),
+ generate_serialization_ (),
+ generate_ostream_ (),
+ generate_doxygen_ (),
+ generate_comparison_ (),
+ generate_default_ctor_ (),
+ generate_from_base_ctor_ (),
+ suppress_assignment_ (),
+ generate_detach_ (),
+ generate_wildcard_ (),
+ generate_any_type_ (),
+ generate_insertion_ (),
+ generate_insertion_specified_ (false),
+ generate_extraction_ (),
+ generate_extraction_specified_ (false),
+ generate_forward_ (),
+ suppress_parsing_ (),
+ generate_element_type_ (),
+ generate_element_map_ (),
+ generate_intellisense_ (),
+ omit_default_attributes_ (),
+ type_naming_ ("knr"),
+ type_naming_specified_ (false),
+ function_naming_ ("knr"),
+ function_naming_specified_ (false),
+ type_regex_ (),
+ type_regex_specified_ (false),
+ accessor_regex_ (),
+ accessor_regex_specified_ (false),
+ one_accessor_regex_ (),
+ one_accessor_regex_specified_ (false),
+ opt_accessor_regex_ (),
+ opt_accessor_regex_specified_ (false),
+ seq_accessor_regex_ (),
+ seq_accessor_regex_specified_ (false),
+ modifier_regex_ (),
+ modifier_regex_specified_ (false),
+ one_modifier_regex_ (),
+ one_modifier_regex_specified_ (false),
+ opt_modifier_regex_ (),
+ opt_modifier_regex_specified_ (false),
+ seq_modifier_regex_ (),
+ seq_modifier_regex_specified_ (false),
+ parser_regex_ (),
+ parser_regex_specified_ (false),
+ serializer_regex_ (),
+ serializer_regex_specified_ (false),
+ const_regex_ (),
+ const_regex_specified_ (false),
+ enumerator_regex_ (),
+ enumerator_regex_specified_ (false),
+ element_type_regex_ (),
+ element_type_regex_specified_ (false),
+ name_regex_trace_ (),
+ root_element_first_ (),
+ root_element_last_ (),
+ root_element_all_ (),
+ root_element_none_ (),
+ root_element_ (),
+ root_element_specified_ (false),
+ custom_type_ (),
+ custom_type_specified_ (false),
+ custom_type_regex_ (),
+ custom_type_regex_specified_ (false),
+ parts_ (1),
+ parts_specified_ (false),
+ parts_suffix_ ("-"),
+ parts_suffix_specified_ (false)
+ {
+ ::cli::argv_scanner s (start, argc, argv, erase);
+ _parse (s, opt, arg);
+ end = s.end ();
+ }
+
+ options::
+ options (::cli::scanner& s,
+ ::cli::unknown_mode opt,
+ ::cli::unknown_mode arg)
+ : generate_polymorphic_ (),
+ polymorphic_type_ (),
+ polymorphic_type_specified_ (false),
+ polymorphic_type_all_ (),
+ polymorphic_plate_ (0),
+ polymorphic_plate_specified_ (false),
+ ordered_type_ (),
+ ordered_type_specified_ (false),
+ ordered_type_derived_ (),
+ ordered_type_mixed_ (),
+ ordered_type_all_ (),
+ order_container_ (),
+ order_container_specified_ (false),
+ generate_serialization_ (),
+ generate_ostream_ (),
+ generate_doxygen_ (),
+ generate_comparison_ (),
+ generate_default_ctor_ (),
+ generate_from_base_ctor_ (),
+ suppress_assignment_ (),
+ generate_detach_ (),
+ generate_wildcard_ (),
+ generate_any_type_ (),
+ generate_insertion_ (),
+ generate_insertion_specified_ (false),
+ generate_extraction_ (),
+ generate_extraction_specified_ (false),
+ generate_forward_ (),
+ suppress_parsing_ (),
+ generate_element_type_ (),
+ generate_element_map_ (),
+ generate_intellisense_ (),
+ omit_default_attributes_ (),
+ type_naming_ ("knr"),
+ type_naming_specified_ (false),
+ function_naming_ ("knr"),
+ function_naming_specified_ (false),
+ type_regex_ (),
+ type_regex_specified_ (false),
+ accessor_regex_ (),
+ accessor_regex_specified_ (false),
+ one_accessor_regex_ (),
+ one_accessor_regex_specified_ (false),
+ opt_accessor_regex_ (),
+ opt_accessor_regex_specified_ (false),
+ seq_accessor_regex_ (),
+ seq_accessor_regex_specified_ (false),
+ modifier_regex_ (),
+ modifier_regex_specified_ (false),
+ one_modifier_regex_ (),
+ one_modifier_regex_specified_ (false),
+ opt_modifier_regex_ (),
+ opt_modifier_regex_specified_ (false),
+ seq_modifier_regex_ (),
+ seq_modifier_regex_specified_ (false),
+ parser_regex_ (),
+ parser_regex_specified_ (false),
+ serializer_regex_ (),
+ serializer_regex_specified_ (false),
+ const_regex_ (),
+ const_regex_specified_ (false),
+ enumerator_regex_ (),
+ enumerator_regex_specified_ (false),
+ element_type_regex_ (),
+ element_type_regex_specified_ (false),
+ name_regex_trace_ (),
+ root_element_first_ (),
+ root_element_last_ (),
+ root_element_all_ (),
+ root_element_none_ (),
+ root_element_ (),
+ root_element_specified_ (false),
+ custom_type_ (),
+ custom_type_specified_ (false),
+ custom_type_regex_ (),
+ custom_type_regex_specified_ (false),
+ parts_ (1),
+ parts_specified_ (false),
+ parts_suffix_ ("-"),
+ parts_suffix_specified_ (false)
+ {
+ _parse (s, opt, arg);
+ }
+
+ void options::
+ print_usage (::std::wostream& os)
+ {
+ os << "--generate-polymorphic Generate polymorphism-aware code." << ::std::endl;
+
+ os << "--polymorphic-type <type> Indicate that <type> is a root of a polymorphic" << ::std::endl
+ << " type hierarchy." << ::std::endl;
+
+ os << "--polymorphic-type-all Indicate that all types should be treated as" << ::std::endl
+ << " polymorphic." << ::std::endl;
+
+ os << "--polymorphic-plate <num> Specify the polymorphic map plate the generated" << ::std::endl
+ << " code should register on." << ::std::endl;
+
+ os << "--ordered-type <type> Indicate that element order in <type> is" << ::std::endl
+ << " significant." << ::std::endl;
+
+ os << "--ordered-type-derived Automatically treat types derived from ordered" << ::std::endl
+ << " bases as also ordered." << ::std::endl;
+
+ os << "--ordered-type-mixed Automatically treat complex types with mixed" << ::std::endl
+ << " content as ordered." << ::std::endl;
+
+ os << "--ordered-type-all Indicate that element order in all types is" << ::std::endl
+ << " significant." << ::std::endl;
+
+ os << "--order-container <type> Specify a custom class template that should be" << ::std::endl
+ << " used as a container for the content order in" << ::std::endl
+ << " ordered types instead of the default" << ::std::endl
+ << " 'std::vector'." << ::std::endl;
+
+ os << "--generate-serialization Generate serialization functions." << ::std::endl;
+
+ os << "--generate-ostream Generate ostream insertion operators" << ::std::endl
+ << " ('operator<<') for generated types." << ::std::endl;
+
+ os << "--generate-doxygen Generate documentation comments suitable for" << ::std::endl
+ << " extraction by the Doxygen documentation system." << ::std::endl;
+
+ os << "--generate-comparison Generate comparison operators ('operator==' and" << ::std::endl
+ << " 'operator!=') for complex types." << ::std::endl;
+
+ os << "--generate-default-ctor Generate default constructors even for types that" << ::std::endl
+ << " have required members." << ::std::endl;
+
+ os << "--generate-from-base-ctor Generate constructors that expect an instance of a" << ::std::endl
+ << " base type followed by all required members." << ::std::endl;
+
+ os << "--suppress-assignment Suppress the generation of copy assignment" << ::std::endl
+ << " operators for complex types." << ::std::endl;
+
+ os << "--generate-detach Generate detach functions for required elements" << ::std::endl
+ << " and attributes." << ::std::endl;
+
+ os << "--generate-wildcard Generate accessors and modifiers as well as" << ::std::endl
+ << " parsing and serialization code for XML Schema" << ::std::endl
+ << " wildcards ('any' and 'anyAttribute')." << ::std::endl;
+
+ os << "--generate-any-type Extract and store content of the XML Schema" << ::std::endl
+ << " 'anyType' type as a DOM fragment." << ::std::endl;
+
+ os << "--generate-insertion <os> Generate data representation stream insertion" << ::std::endl
+ << " operators for the <os> output stream type." << ::std::endl;
+
+ os << "--generate-extraction <is> Generate data representation stream extraction" << ::std::endl
+ << " constructors for the <is> input stream type." << ::std::endl;
+
+ os << "--generate-forward Generate a separate header file with forward" << ::std::endl
+ << " declarations for the types being generated." << ::std::endl;
+
+ os << "--suppress-parsing Suppress the generation of the parsing functions" << ::std::endl
+ << " and constructors." << ::std::endl;
+
+ os << "--generate-element-type Generate types instead of parsing and" << ::std::endl
+ << " serialization functions for root elements." << ::std::endl;
+
+ os << "--generate-element-map Generate a root element map that allows uniform" << ::std::endl
+ << " parsing and serialization of multiple root" << ::std::endl
+ << " elements." << ::std::endl;
+
+ os << "--generate-intellisense Generate workarounds for IntelliSense bugs in" << ::std::endl
+ << " Visual Studio 2005 (8.0)." << ::std::endl;
+
+ os << "--omit-default-attributes Omit attributes with default and fixed values from" << ::std::endl
+ << " serialized XML documents." << ::std::endl;
+
+ os << "--type-naming <style> Specify the type naming convention that should be" << ::std::endl
+ << " used in the generated code." << ::std::endl;
+
+ os << "--function-naming <style> Specify the function naming convention that should" << ::std::endl
+ << " be used in the generated code." << ::std::endl;
+
+ os << "--type-regex <regex> Add <regex> to the list of regular expressions" << ::std::endl
+ << " used to translate XML Schema type names to C++" << ::std::endl
+ << " type names." << ::std::endl;
+
+ os << "--accessor-regex <regex> Add <regex> to the list of regular expressions" << ::std::endl
+ << " used to translate XML Schema names of" << ::std::endl
+ << " elements/attributes to C++ accessor function" << ::std::endl
+ << " names." << ::std::endl;
+
+ os << "--one-accessor-regex <regex> Add <regex> to the list of regular expressions" << ::std::endl
+ << " used to translate XML Schema names of" << ::std::endl
+ << " elements/attributes with cardinality one to C++" << ::std::endl
+ << " accessor function names." << ::std::endl;
+
+ os << "--opt-accessor-regex <regex> Add <regex> to the list of regular expressions" << ::std::endl
+ << " used to translate XML Schema names of" << ::std::endl
+ << " elements/attributes with cardinality optional to" << ::std::endl
+ << " C++ accessor function names." << ::std::endl;
+
+ os << "--seq-accessor-regex <regex> Add <regex> to the list of regular expressions" << ::std::endl
+ << " used to translate XML Schema names of" << ::std::endl
+ << " elements/attributes with cardinality sequence to" << ::std::endl
+ << " C++ accessor function names." << ::std::endl;
+
+ os << "--modifier-regex <regex> Add <regex> to the list of regular expressions" << ::std::endl
+ << " used to translate XML Schema names of" << ::std::endl
+ << " elements/attributes to C++ modifier function" << ::std::endl
+ << " names." << ::std::endl;
+
+ os << "--one-modifier-regex <regex> Add <regex> to the list of regular expressions" << ::std::endl
+ << " used to translate XML Schema names of" << ::std::endl
+ << " elements/attributes with cardinality one to C++" << ::std::endl
+ << " modifier function names." << ::std::endl;
+
+ os << "--opt-modifier-regex <regex> Add <regex> to the list of regular expressions" << ::std::endl
+ << " used to translate XML Schema names of" << ::std::endl
+ << " elements/attributes with cardinality optional to" << ::std::endl
+ << " C++ modifier function names." << ::std::endl;
+
+ os << "--seq-modifier-regex <regex> Add <regex> to the list of regular expressions" << ::std::endl
+ << " used to translate XML Schema names of" << ::std::endl
+ << " elements/attributes with cardinality sequence to" << ::std::endl
+ << " C++ modifier function names." << ::std::endl;
+
+ os << "--parser-regex <regex> Add <regex> to the list of regular expressions" << ::std::endl
+ << " used to translate XML Schema element names to C++" << ::std::endl
+ << " parsing function names." << ::std::endl;
+
+ os << "--serializer-regex <regex> Add <regex> to the list of regular expressions" << ::std::endl
+ << " used to translate XML Schema element names to C++" << ::std::endl
+ << " serialization function names." << ::std::endl;
+
+ os << "--const-regex <regex> Add <regex> to the list of regular expressions" << ::std::endl
+ << " used to translate XML Schema-derived names to C++" << ::std::endl
+ << " constant names." << ::std::endl;
+
+ os << "--enumerator-regex <regex> Add <regex> to the list of regular expressions" << ::std::endl
+ << " used to translate XML Schema enumeration values to" << ::std::endl
+ << " C++ enumerator names." << ::std::endl;
+
+ os << "--element-type-regex <regex> Add <regex> to the list of regular expressions" << ::std::endl
+ << " used to translate XML Schema element names to C++" << ::std::endl
+ << " element type names." << ::std::endl;
+
+ os << "--name-regex-trace Trace the process of applying regular expressions" << ::std::endl
+ << " specified with the name transformation options." << ::std::endl;
+
+ os << "--root-element-first Treat only the first global element as a document" << ::std::endl
+ << " root." << ::std::endl;
+
+ os << "--root-element-last Treat only the last global element as a document" << ::std::endl
+ << " root." << ::std::endl;
+
+ os << "--root-element-all Treat all global elements as document roots." << ::std::endl;
+
+ os << "--root-element-none Do not treat any global elements as document" << ::std::endl
+ << " roots." << ::std::endl;
+
+ os << "--root-element <element> Treat only <element> as a document root." << ::std::endl;
+
+ os << "--custom-type <map> Use a custom C++ type instead of the generated" << ::std::endl
+ << " class." << ::std::endl;
+
+ os << "--custom-type-regex <regex> Use custom C++ types instead of the generated" << ::std::endl
+ << " classes." << ::std::endl;
+
+ os << "--parts <num> Split generated source code into <num> parts." << ::std::endl;
+
+ os << "--parts-suffix <suffix> Use <suffix> instead of the default ''-'' to" << ::std::endl
+ << " separate the file name from the part number." << ::std::endl;
+ }
+
+ typedef
+ std::map<std::string, void (*) (options&, ::cli::scanner&)>
+ _cli_options_map;
+
+ static _cli_options_map _cli_options_map_;
+
+ struct _cli_options_map_init
+ {
+ _cli_options_map_init ()
+ {
+ _cli_options_map_["--generate-polymorphic"] =
+ &::cli::thunk< options, bool, &options::generate_polymorphic_ >;
+ _cli_options_map_["--polymorphic-type"] =
+ &::cli::thunk< options, NarrowStrings, &options::polymorphic_type_,
+ &options::polymorphic_type_specified_ >;
+ _cli_options_map_["--polymorphic-type-all"] =
+ &::cli::thunk< options, bool, &options::polymorphic_type_all_ >;
+ _cli_options_map_["--polymorphic-plate"] =
+ &::cli::thunk< options, unsigned long, &options::polymorphic_plate_,
+ &options::polymorphic_plate_specified_ >;
+ _cli_options_map_["--ordered-type"] =
+ &::cli::thunk< options, NarrowStrings, &options::ordered_type_,
+ &options::ordered_type_specified_ >;
+ _cli_options_map_["--ordered-type-derived"] =
+ &::cli::thunk< options, bool, &options::ordered_type_derived_ >;
+ _cli_options_map_["--ordered-type-mixed"] =
+ &::cli::thunk< options, bool, &options::ordered_type_mixed_ >;
+ _cli_options_map_["--ordered-type-all"] =
+ &::cli::thunk< options, bool, &options::ordered_type_all_ >;
+ _cli_options_map_["--order-container"] =
+ &::cli::thunk< options, NarrowString, &options::order_container_,
+ &options::order_container_specified_ >;
+ _cli_options_map_["--generate-serialization"] =
+ &::cli::thunk< options, bool, &options::generate_serialization_ >;
+ _cli_options_map_["--generate-ostream"] =
+ &::cli::thunk< options, bool, &options::generate_ostream_ >;
+ _cli_options_map_["--generate-doxygen"] =
+ &::cli::thunk< options, bool, &options::generate_doxygen_ >;
+ _cli_options_map_["--generate-comparison"] =
+ &::cli::thunk< options, bool, &options::generate_comparison_ >;
+ _cli_options_map_["--generate-default-ctor"] =
+ &::cli::thunk< options, bool, &options::generate_default_ctor_ >;
+ _cli_options_map_["--generate-from-base-ctor"] =
+ &::cli::thunk< options, bool, &options::generate_from_base_ctor_ >;
+ _cli_options_map_["--suppress-assignment"] =
+ &::cli::thunk< options, bool, &options::suppress_assignment_ >;
+ _cli_options_map_["--generate-detach"] =
+ &::cli::thunk< options, bool, &options::generate_detach_ >;
+ _cli_options_map_["--generate-wildcard"] =
+ &::cli::thunk< options, bool, &options::generate_wildcard_ >;
+ _cli_options_map_["--generate-any-type"] =
+ &::cli::thunk< options, bool, &options::generate_any_type_ >;
+ _cli_options_map_["--generate-insertion"] =
+ &::cli::thunk< options, NarrowStrings, &options::generate_insertion_,
+ &options::generate_insertion_specified_ >;
+ _cli_options_map_["--generate-extraction"] =
+ &::cli::thunk< options, NarrowStrings, &options::generate_extraction_,
+ &options::generate_extraction_specified_ >;
+ _cli_options_map_["--generate-forward"] =
+ &::cli::thunk< options, bool, &options::generate_forward_ >;
+ _cli_options_map_["--suppress-parsing"] =
+ &::cli::thunk< options, bool, &options::suppress_parsing_ >;
+ _cli_options_map_["--generate-element-type"] =
+ &::cli::thunk< options, bool, &options::generate_element_type_ >;
+ _cli_options_map_["--generate-element-map"] =
+ &::cli::thunk< options, bool, &options::generate_element_map_ >;
+ _cli_options_map_["--generate-intellisense"] =
+ &::cli::thunk< options, bool, &options::generate_intellisense_ >;
+ _cli_options_map_["--omit-default-attributes"] =
+ &::cli::thunk< options, bool, &options::omit_default_attributes_ >;
+ _cli_options_map_["--type-naming"] =
+ &::cli::thunk< options, NarrowString, &options::type_naming_,
+ &options::type_naming_specified_ >;
+ _cli_options_map_["--function-naming"] =
+ &::cli::thunk< options, NarrowString, &options::function_naming_,
+ &options::function_naming_specified_ >;
+ _cli_options_map_["--type-regex"] =
+ &::cli::thunk< options, NarrowStrings, &options::type_regex_,
+ &options::type_regex_specified_ >;
+ _cli_options_map_["--accessor-regex"] =
+ &::cli::thunk< options, NarrowStrings, &options::accessor_regex_,
+ &options::accessor_regex_specified_ >;
+ _cli_options_map_["--one-accessor-regex"] =
+ &::cli::thunk< options, NarrowStrings, &options::one_accessor_regex_,
+ &options::one_accessor_regex_specified_ >;
+ _cli_options_map_["--opt-accessor-regex"] =
+ &::cli::thunk< options, NarrowStrings, &options::opt_accessor_regex_,
+ &options::opt_accessor_regex_specified_ >;
+ _cli_options_map_["--seq-accessor-regex"] =
+ &::cli::thunk< options, NarrowStrings, &options::seq_accessor_regex_,
+ &options::seq_accessor_regex_specified_ >;
+ _cli_options_map_["--modifier-regex"] =
+ &::cli::thunk< options, NarrowStrings, &options::modifier_regex_,
+ &options::modifier_regex_specified_ >;
+ _cli_options_map_["--one-modifier-regex"] =
+ &::cli::thunk< options, NarrowStrings, &options::one_modifier_regex_,
+ &options::one_modifier_regex_specified_ >;
+ _cli_options_map_["--opt-modifier-regex"] =
+ &::cli::thunk< options, NarrowStrings, &options::opt_modifier_regex_,
+ &options::opt_modifier_regex_specified_ >;
+ _cli_options_map_["--seq-modifier-regex"] =
+ &::cli::thunk< options, NarrowStrings, &options::seq_modifier_regex_,
+ &options::seq_modifier_regex_specified_ >;
+ _cli_options_map_["--parser-regex"] =
+ &::cli::thunk< options, NarrowStrings, &options::parser_regex_,
+ &options::parser_regex_specified_ >;
+ _cli_options_map_["--serializer-regex"] =
+ &::cli::thunk< options, NarrowStrings, &options::serializer_regex_,
+ &options::serializer_regex_specified_ >;
+ _cli_options_map_["--const-regex"] =
+ &::cli::thunk< options, NarrowStrings, &options::const_regex_,
+ &options::const_regex_specified_ >;
+ _cli_options_map_["--enumerator-regex"] =
+ &::cli::thunk< options, NarrowStrings, &options::enumerator_regex_,
+ &options::enumerator_regex_specified_ >;
+ _cli_options_map_["--element-type-regex"] =
+ &::cli::thunk< options, NarrowStrings, &options::element_type_regex_,
+ &options::element_type_regex_specified_ >;
+ _cli_options_map_["--name-regex-trace"] =
+ &::cli::thunk< options, bool, &options::name_regex_trace_ >;
+ _cli_options_map_["--root-element-first"] =
+ &::cli::thunk< options, bool, &options::root_element_first_ >;
+ _cli_options_map_["--root-element-last"] =
+ &::cli::thunk< options, bool, &options::root_element_last_ >;
+ _cli_options_map_["--root-element-all"] =
+ &::cli::thunk< options, bool, &options::root_element_all_ >;
+ _cli_options_map_["--root-element-none"] =
+ &::cli::thunk< options, bool, &options::root_element_none_ >;
+ _cli_options_map_["--root-element"] =
+ &::cli::thunk< options, NarrowStrings, &options::root_element_,
+ &options::root_element_specified_ >;
+ _cli_options_map_["--custom-type"] =
+ &::cli::thunk< options, NarrowStrings, &options::custom_type_,
+ &options::custom_type_specified_ >;
+ _cli_options_map_["--custom-type-regex"] =
+ &::cli::thunk< options, NarrowStrings, &options::custom_type_regex_,
+ &options::custom_type_regex_specified_ >;
+ _cli_options_map_["--parts"] =
+ &::cli::thunk< options, std::size_t, &options::parts_,
+ &options::parts_specified_ >;
+ _cli_options_map_["--parts-suffix"] =
+ &::cli::thunk< options, NarrowString, &options::parts_suffix_,
+ &options::parts_suffix_specified_ >;
+ }
+ };
+
+ static _cli_options_map_init _cli_options_map_init_;
+
+ bool options::
+ _parse (const char* o, ::cli::scanner& s)
+ {
+ _cli_options_map::const_iterator i (_cli_options_map_.find (o));
+
+ if (i != _cli_options_map_.end ())
+ {
+ (*(i->second)) (*this, s);
+ return true;
+ }
+
+ // options base
+ //
+ if (::CXX::options::_parse (o, s))
+ return true;
+
+ return false;
+ }
+
+ void options::
+ _parse (::cli::scanner& s,
+ ::cli::unknown_mode opt_mode,
+ ::cli::unknown_mode arg_mode)
+ {
+ bool opt = true;
+
+ while (s.more ())
+ {
+ const char* o = s.peek ();
+
+ if (std::strcmp (o, "--") == 0)
+ {
+ s.skip ();
+ opt = false;
+ continue;
+ }
+
+ if (opt && _parse (o, s));
+ else if (opt && std::strncmp (o, "-", 1) == 0 && o[1] != '\0')
+ {
+ switch (opt_mode)
+ {
+ case ::cli::unknown_mode::skip:
+ {
+ s.skip ();
+ continue;
+ }
+ case ::cli::unknown_mode::stop:
+ {
+ break;
+ }
+ case ::cli::unknown_mode::fail:
+ {
+ throw ::cli::unknown_option (o);
+ }
+ }
+
+ break;
+ }
+ else
+ {
+ switch (arg_mode)
+ {
+ case ::cli::unknown_mode::skip:
+ {
+ s.skip ();
+ continue;
+ }
+ case ::cli::unknown_mode::stop:
+ {
+ break;
+ }
+ case ::cli::unknown_mode::fail:
+ {
+ throw ::cli::unknown_argument (o);
+ }
+ }
+
+ break;
+ }
+ }
+ }
+ }
+}
+
+// Begin epilogue.
+//
+//
+// End epilogue.
+
diff --git a/xsd/xsd/cxx/tree/options.hxx b/xsd/xsd/cxx/tree/options.hxx
new file mode 100644
index 0000000..b190dc5
--- /dev/null
+++ b/xsd/xsd/cxx/tree/options.hxx
@@ -0,0 +1,411 @@
+// This code was generated by CLI, a command line interface
+// compiler for C++.
+//
+
+#ifndef CXX_TREE_OPTIONS_HXX
+#define CXX_TREE_OPTIONS_HXX
+
+// Begin prologue.
+//
+//
+// End prologue.
+
+#include <cstddef>
+
+#include <types.hxx>
+
+#include <cxx/options.hxx>
+
+namespace CXX
+{
+ namespace Tree
+ {
+ class options: public ::CXX::options
+ {
+ public:
+ options (int& argc,
+ char** argv,
+ bool erase = false,
+ ::cli::unknown_mode option = ::cli::unknown_mode::fail,
+ ::cli::unknown_mode argument = ::cli::unknown_mode::stop);
+
+ options (int start,
+ int& argc,
+ char** argv,
+ bool erase = false,
+ ::cli::unknown_mode option = ::cli::unknown_mode::fail,
+ ::cli::unknown_mode argument = ::cli::unknown_mode::stop);
+
+ options (int& argc,
+ char** argv,
+ int& end,
+ bool erase = false,
+ ::cli::unknown_mode option = ::cli::unknown_mode::fail,
+ ::cli::unknown_mode argument = ::cli::unknown_mode::stop);
+
+ options (int start,
+ int& argc,
+ char** argv,
+ int& end,
+ bool erase = false,
+ ::cli::unknown_mode option = ::cli::unknown_mode::fail,
+ ::cli::unknown_mode argument = ::cli::unknown_mode::stop);
+
+ options (::cli::scanner&,
+ ::cli::unknown_mode option = ::cli::unknown_mode::fail,
+ ::cli::unknown_mode argument = ::cli::unknown_mode::stop);
+
+ options ();
+
+ // Option accessors.
+ //
+ const bool&
+ generate_polymorphic () const;
+
+ const NarrowStrings&
+ polymorphic_type () const;
+
+ bool
+ polymorphic_type_specified () const;
+
+ const bool&
+ polymorphic_type_all () const;
+
+ const unsigned long&
+ polymorphic_plate () const;
+
+ bool
+ polymorphic_plate_specified () const;
+
+ const NarrowStrings&
+ ordered_type () const;
+
+ bool
+ ordered_type_specified () const;
+
+ const bool&
+ ordered_type_derived () const;
+
+ const bool&
+ ordered_type_mixed () const;
+
+ const bool&
+ ordered_type_all () const;
+
+ const NarrowString&
+ order_container () const;
+
+ bool
+ order_container_specified () const;
+
+ const bool&
+ generate_serialization () const;
+
+ const bool&
+ generate_ostream () const;
+
+ const bool&
+ generate_doxygen () const;
+
+ const bool&
+ generate_comparison () const;
+
+ const bool&
+ generate_default_ctor () const;
+
+ const bool&
+ generate_from_base_ctor () const;
+
+ const bool&
+ suppress_assignment () const;
+
+ const bool&
+ generate_detach () const;
+
+ const bool&
+ generate_wildcard () const;
+
+ const bool&
+ generate_any_type () const;
+
+ const NarrowStrings&
+ generate_insertion () const;
+
+ bool
+ generate_insertion_specified () const;
+
+ const NarrowStrings&
+ generate_extraction () const;
+
+ bool
+ generate_extraction_specified () const;
+
+ const bool&
+ generate_forward () const;
+
+ const bool&
+ suppress_parsing () const;
+
+ const bool&
+ generate_element_type () const;
+
+ const bool&
+ generate_element_map () const;
+
+ const bool&
+ generate_intellisense () const;
+
+ const bool&
+ omit_default_attributes () const;
+
+ const NarrowString&
+ type_naming () const;
+
+ bool
+ type_naming_specified () const;
+
+ const NarrowString&
+ function_naming () const;
+
+ bool
+ function_naming_specified () const;
+
+ const NarrowStrings&
+ type_regex () const;
+
+ bool
+ type_regex_specified () const;
+
+ const NarrowStrings&
+ accessor_regex () const;
+
+ bool
+ accessor_regex_specified () const;
+
+ const NarrowStrings&
+ one_accessor_regex () const;
+
+ bool
+ one_accessor_regex_specified () const;
+
+ const NarrowStrings&
+ opt_accessor_regex () const;
+
+ bool
+ opt_accessor_regex_specified () const;
+
+ const NarrowStrings&
+ seq_accessor_regex () const;
+
+ bool
+ seq_accessor_regex_specified () const;
+
+ const NarrowStrings&
+ modifier_regex () const;
+
+ bool
+ modifier_regex_specified () const;
+
+ const NarrowStrings&
+ one_modifier_regex () const;
+
+ bool
+ one_modifier_regex_specified () const;
+
+ const NarrowStrings&
+ opt_modifier_regex () const;
+
+ bool
+ opt_modifier_regex_specified () const;
+
+ const NarrowStrings&
+ seq_modifier_regex () const;
+
+ bool
+ seq_modifier_regex_specified () const;
+
+ const NarrowStrings&
+ parser_regex () const;
+
+ bool
+ parser_regex_specified () const;
+
+ const NarrowStrings&
+ serializer_regex () const;
+
+ bool
+ serializer_regex_specified () const;
+
+ const NarrowStrings&
+ const_regex () const;
+
+ bool
+ const_regex_specified () const;
+
+ const NarrowStrings&
+ enumerator_regex () const;
+
+ bool
+ enumerator_regex_specified () const;
+
+ const NarrowStrings&
+ element_type_regex () const;
+
+ bool
+ element_type_regex_specified () const;
+
+ const bool&
+ name_regex_trace () const;
+
+ const bool&
+ root_element_first () const;
+
+ const bool&
+ root_element_last () const;
+
+ const bool&
+ root_element_all () const;
+
+ const bool&
+ root_element_none () const;
+
+ const NarrowStrings&
+ root_element () const;
+
+ bool
+ root_element_specified () const;
+
+ const NarrowStrings&
+ custom_type () const;
+
+ bool
+ custom_type_specified () const;
+
+ const NarrowStrings&
+ custom_type_regex () const;
+
+ bool
+ custom_type_regex_specified () const;
+
+ const std::size_t&
+ parts () const;
+
+ bool
+ parts_specified () const;
+
+ const NarrowString&
+ parts_suffix () const;
+
+ bool
+ parts_suffix_specified () const;
+
+ // Print usage information.
+ //
+ static void
+ print_usage (::std::wostream&);
+
+ // Implementation details.
+ //
+ protected:
+ bool
+ _parse (const char*, ::cli::scanner&);
+
+ private:
+ void
+ _parse (::cli::scanner&,
+ ::cli::unknown_mode option,
+ ::cli::unknown_mode argument);
+
+ public:
+ bool generate_polymorphic_;
+ NarrowStrings polymorphic_type_;
+ bool polymorphic_type_specified_;
+ bool polymorphic_type_all_;
+ unsigned long polymorphic_plate_;
+ bool polymorphic_plate_specified_;
+ NarrowStrings ordered_type_;
+ bool ordered_type_specified_;
+ bool ordered_type_derived_;
+ bool ordered_type_mixed_;
+ bool ordered_type_all_;
+ NarrowString order_container_;
+ bool order_container_specified_;
+ bool generate_serialization_;
+ bool generate_ostream_;
+ bool generate_doxygen_;
+ bool generate_comparison_;
+ bool generate_default_ctor_;
+ bool generate_from_base_ctor_;
+ bool suppress_assignment_;
+ bool generate_detach_;
+ bool generate_wildcard_;
+ bool generate_any_type_;
+ NarrowStrings generate_insertion_;
+ bool generate_insertion_specified_;
+ NarrowStrings generate_extraction_;
+ bool generate_extraction_specified_;
+ bool generate_forward_;
+ bool suppress_parsing_;
+ bool generate_element_type_;
+ bool generate_element_map_;
+ bool generate_intellisense_;
+ bool omit_default_attributes_;
+ NarrowString type_naming_;
+ bool type_naming_specified_;
+ NarrowString function_naming_;
+ bool function_naming_specified_;
+ NarrowStrings type_regex_;
+ bool type_regex_specified_;
+ NarrowStrings accessor_regex_;
+ bool accessor_regex_specified_;
+ NarrowStrings one_accessor_regex_;
+ bool one_accessor_regex_specified_;
+ NarrowStrings opt_accessor_regex_;
+ bool opt_accessor_regex_specified_;
+ NarrowStrings seq_accessor_regex_;
+ bool seq_accessor_regex_specified_;
+ NarrowStrings modifier_regex_;
+ bool modifier_regex_specified_;
+ NarrowStrings one_modifier_regex_;
+ bool one_modifier_regex_specified_;
+ NarrowStrings opt_modifier_regex_;
+ bool opt_modifier_regex_specified_;
+ NarrowStrings seq_modifier_regex_;
+ bool seq_modifier_regex_specified_;
+ NarrowStrings parser_regex_;
+ bool parser_regex_specified_;
+ NarrowStrings serializer_regex_;
+ bool serializer_regex_specified_;
+ NarrowStrings const_regex_;
+ bool const_regex_specified_;
+ NarrowStrings enumerator_regex_;
+ bool enumerator_regex_specified_;
+ NarrowStrings element_type_regex_;
+ bool element_type_regex_specified_;
+ bool name_regex_trace_;
+ bool root_element_first_;
+ bool root_element_last_;
+ bool root_element_all_;
+ bool root_element_none_;
+ NarrowStrings root_element_;
+ bool root_element_specified_;
+ NarrowStrings custom_type_;
+ bool custom_type_specified_;
+ NarrowStrings custom_type_regex_;
+ bool custom_type_regex_specified_;
+ std::size_t parts_;
+ bool parts_specified_;
+ NarrowString parts_suffix_;
+ bool parts_suffix_specified_;
+ };
+ }
+}
+
+#include <cxx/tree/options.ixx>
+
+// Begin epilogue.
+//
+//
+// End epilogue.
+
+#endif // CXX_TREE_OPTIONS_HXX
diff --git a/xsd/xsd/cxx/tree/options.ixx b/xsd/xsd/cxx/tree/options.ixx
new file mode 100644
index 0000000..824fbee
--- /dev/null
+++ b/xsd/xsd/cxx/tree/options.ixx
@@ -0,0 +1,502 @@
+// This code was generated by CLI, a command line interface
+// compiler for C++.
+//
+
+// Begin prologue.
+//
+//
+// End prologue.
+
+namespace CXX
+{
+ namespace Tree
+ {
+ // options
+ //
+
+ inline const bool& options::
+ generate_polymorphic () const
+ {
+ return this->generate_polymorphic_;
+ }
+
+ inline const NarrowStrings& options::
+ polymorphic_type () const
+ {
+ return this->polymorphic_type_;
+ }
+
+ inline bool options::
+ polymorphic_type_specified () const
+ {
+ return this->polymorphic_type_specified_;
+ }
+
+ inline const bool& options::
+ polymorphic_type_all () const
+ {
+ return this->polymorphic_type_all_;
+ }
+
+ inline const unsigned long& options::
+ polymorphic_plate () const
+ {
+ return this->polymorphic_plate_;
+ }
+
+ inline bool options::
+ polymorphic_plate_specified () const
+ {
+ return this->polymorphic_plate_specified_;
+ }
+
+ inline const NarrowStrings& options::
+ ordered_type () const
+ {
+ return this->ordered_type_;
+ }
+
+ inline bool options::
+ ordered_type_specified () const
+ {
+ return this->ordered_type_specified_;
+ }
+
+ inline const bool& options::
+ ordered_type_derived () const
+ {
+ return this->ordered_type_derived_;
+ }
+
+ inline const bool& options::
+ ordered_type_mixed () const
+ {
+ return this->ordered_type_mixed_;
+ }
+
+ inline const bool& options::
+ ordered_type_all () const
+ {
+ return this->ordered_type_all_;
+ }
+
+ inline const NarrowString& options::
+ order_container () const
+ {
+ return this->order_container_;
+ }
+
+ inline bool options::
+ order_container_specified () const
+ {
+ return this->order_container_specified_;
+ }
+
+ inline const bool& options::
+ generate_serialization () const
+ {
+ return this->generate_serialization_;
+ }
+
+ inline const bool& options::
+ generate_ostream () const
+ {
+ return this->generate_ostream_;
+ }
+
+ inline const bool& options::
+ generate_doxygen () const
+ {
+ return this->generate_doxygen_;
+ }
+
+ inline const bool& options::
+ generate_comparison () const
+ {
+ return this->generate_comparison_;
+ }
+
+ inline const bool& options::
+ generate_default_ctor () const
+ {
+ return this->generate_default_ctor_;
+ }
+
+ inline const bool& options::
+ generate_from_base_ctor () const
+ {
+ return this->generate_from_base_ctor_;
+ }
+
+ inline const bool& options::
+ suppress_assignment () const
+ {
+ return this->suppress_assignment_;
+ }
+
+ inline const bool& options::
+ generate_detach () const
+ {
+ return this->generate_detach_;
+ }
+
+ inline const bool& options::
+ generate_wildcard () const
+ {
+ return this->generate_wildcard_;
+ }
+
+ inline const bool& options::
+ generate_any_type () const
+ {
+ return this->generate_any_type_;
+ }
+
+ inline const NarrowStrings& options::
+ generate_insertion () const
+ {
+ return this->generate_insertion_;
+ }
+
+ inline bool options::
+ generate_insertion_specified () const
+ {
+ return this->generate_insertion_specified_;
+ }
+
+ inline const NarrowStrings& options::
+ generate_extraction () const
+ {
+ return this->generate_extraction_;
+ }
+
+ inline bool options::
+ generate_extraction_specified () const
+ {
+ return this->generate_extraction_specified_;
+ }
+
+ inline const bool& options::
+ generate_forward () const
+ {
+ return this->generate_forward_;
+ }
+
+ inline const bool& options::
+ suppress_parsing () const
+ {
+ return this->suppress_parsing_;
+ }
+
+ inline const bool& options::
+ generate_element_type () const
+ {
+ return this->generate_element_type_;
+ }
+
+ inline const bool& options::
+ generate_element_map () const
+ {
+ return this->generate_element_map_;
+ }
+
+ inline const bool& options::
+ generate_intellisense () const
+ {
+ return this->generate_intellisense_;
+ }
+
+ inline const bool& options::
+ omit_default_attributes () const
+ {
+ return this->omit_default_attributes_;
+ }
+
+ inline const NarrowString& options::
+ type_naming () const
+ {
+ return this->type_naming_;
+ }
+
+ inline bool options::
+ type_naming_specified () const
+ {
+ return this->type_naming_specified_;
+ }
+
+ inline const NarrowString& options::
+ function_naming () const
+ {
+ return this->function_naming_;
+ }
+
+ inline bool options::
+ function_naming_specified () const
+ {
+ return this->function_naming_specified_;
+ }
+
+ inline const NarrowStrings& options::
+ type_regex () const
+ {
+ return this->type_regex_;
+ }
+
+ inline bool options::
+ type_regex_specified () const
+ {
+ return this->type_regex_specified_;
+ }
+
+ inline const NarrowStrings& options::
+ accessor_regex () const
+ {
+ return this->accessor_regex_;
+ }
+
+ inline bool options::
+ accessor_regex_specified () const
+ {
+ return this->accessor_regex_specified_;
+ }
+
+ inline const NarrowStrings& options::
+ one_accessor_regex () const
+ {
+ return this->one_accessor_regex_;
+ }
+
+ inline bool options::
+ one_accessor_regex_specified () const
+ {
+ return this->one_accessor_regex_specified_;
+ }
+
+ inline const NarrowStrings& options::
+ opt_accessor_regex () const
+ {
+ return this->opt_accessor_regex_;
+ }
+
+ inline bool options::
+ opt_accessor_regex_specified () const
+ {
+ return this->opt_accessor_regex_specified_;
+ }
+
+ inline const NarrowStrings& options::
+ seq_accessor_regex () const
+ {
+ return this->seq_accessor_regex_;
+ }
+
+ inline bool options::
+ seq_accessor_regex_specified () const
+ {
+ return this->seq_accessor_regex_specified_;
+ }
+
+ inline const NarrowStrings& options::
+ modifier_regex () const
+ {
+ return this->modifier_regex_;
+ }
+
+ inline bool options::
+ modifier_regex_specified () const
+ {
+ return this->modifier_regex_specified_;
+ }
+
+ inline const NarrowStrings& options::
+ one_modifier_regex () const
+ {
+ return this->one_modifier_regex_;
+ }
+
+ inline bool options::
+ one_modifier_regex_specified () const
+ {
+ return this->one_modifier_regex_specified_;
+ }
+
+ inline const NarrowStrings& options::
+ opt_modifier_regex () const
+ {
+ return this->opt_modifier_regex_;
+ }
+
+ inline bool options::
+ opt_modifier_regex_specified () const
+ {
+ return this->opt_modifier_regex_specified_;
+ }
+
+ inline const NarrowStrings& options::
+ seq_modifier_regex () const
+ {
+ return this->seq_modifier_regex_;
+ }
+
+ inline bool options::
+ seq_modifier_regex_specified () const
+ {
+ return this->seq_modifier_regex_specified_;
+ }
+
+ inline const NarrowStrings& options::
+ parser_regex () const
+ {
+ return this->parser_regex_;
+ }
+
+ inline bool options::
+ parser_regex_specified () const
+ {
+ return this->parser_regex_specified_;
+ }
+
+ inline const NarrowStrings& options::
+ serializer_regex () const
+ {
+ return this->serializer_regex_;
+ }
+
+ inline bool options::
+ serializer_regex_specified () const
+ {
+ return this->serializer_regex_specified_;
+ }
+
+ inline const NarrowStrings& options::
+ const_regex () const
+ {
+ return this->const_regex_;
+ }
+
+ inline bool options::
+ const_regex_specified () const
+ {
+ return this->const_regex_specified_;
+ }
+
+ inline const NarrowStrings& options::
+ enumerator_regex () const
+ {
+ return this->enumerator_regex_;
+ }
+
+ inline bool options::
+ enumerator_regex_specified () const
+ {
+ return this->enumerator_regex_specified_;
+ }
+
+ inline const NarrowStrings& options::
+ element_type_regex () const
+ {
+ return this->element_type_regex_;
+ }
+
+ inline bool options::
+ element_type_regex_specified () const
+ {
+ return this->element_type_regex_specified_;
+ }
+
+ inline const bool& options::
+ name_regex_trace () const
+ {
+ return this->name_regex_trace_;
+ }
+
+ inline const bool& options::
+ root_element_first () const
+ {
+ return this->root_element_first_;
+ }
+
+ inline const bool& options::
+ root_element_last () const
+ {
+ return this->root_element_last_;
+ }
+
+ inline const bool& options::
+ root_element_all () const
+ {
+ return this->root_element_all_;
+ }
+
+ inline const bool& options::
+ root_element_none () const
+ {
+ return this->root_element_none_;
+ }
+
+ inline const NarrowStrings& options::
+ root_element () const
+ {
+ return this->root_element_;
+ }
+
+ inline bool options::
+ root_element_specified () const
+ {
+ return this->root_element_specified_;
+ }
+
+ inline const NarrowStrings& options::
+ custom_type () const
+ {
+ return this->custom_type_;
+ }
+
+ inline bool options::
+ custom_type_specified () const
+ {
+ return this->custom_type_specified_;
+ }
+
+ inline const NarrowStrings& options::
+ custom_type_regex () const
+ {
+ return this->custom_type_regex_;
+ }
+
+ inline bool options::
+ custom_type_regex_specified () const
+ {
+ return this->custom_type_regex_specified_;
+ }
+
+ inline const std::size_t& options::
+ parts () const
+ {
+ return this->parts_;
+ }
+
+ inline bool options::
+ parts_specified () const
+ {
+ return this->parts_specified_;
+ }
+
+ inline const NarrowString& options::
+ parts_suffix () const
+ {
+ return this->parts_suffix_;
+ }
+
+ inline bool options::
+ parts_suffix_specified () const
+ {
+ return this->parts_suffix_specified_;
+ }
+ }
+}
+
+// Begin epilogue.
+//
+//
+// End epilogue.
diff --git a/xsd/xsd/cxx/tree/order-processor.cxx b/xsd/xsd/cxx/tree/order-processor.cxx
new file mode 100644
index 0000000..68eee8c
--- /dev/null
+++ b/xsd/xsd/cxx/tree/order-processor.cxx
@@ -0,0 +1,244 @@
+// file : xsde/cxx/tree/order-processor.cxx
+// copyright : Copyright (c) 2006-2014 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#include <iostream>
+
+#include <cxx/tree/elements.hxx>
+#include <cxx/tree/order-processor.hxx>
+
+#include <xsd-frontend/semantic-graph.hxx>
+#include <xsd-frontend/traversal.hxx>
+
+using namespace std;
+
+namespace CXX
+{
+ namespace Tree
+ {
+ namespace
+ {
+ struct Member: Traversal::Element, Traversal::Any
+ {
+ Member (size_t count): count_ (count) {}
+
+ virtual void
+ traverse (SemanticGraph::Element& e)
+ {
+ if (Context::skip (e))
+ return;
+
+ e.context ().set ("ordered-id", count_++);
+ }
+
+ virtual void
+ traverse (SemanticGraph::Any& a)
+ {
+ a.context ().set ("ordered-id", count_++);
+ }
+
+ size_t count_;
+ };
+
+ //
+ //
+ struct Type: Traversal::Complex
+ {
+ Type (TypeNameSet& ordered_types, bool derived, bool mixed, bool all)
+ : ordered_types_ (ordered_types),
+ derived_ (derived),
+ mixed_ (mixed),
+ all_ (all)
+ {
+ }
+
+ virtual void
+ traverse (SemanticGraph::Complex& c)
+ {
+ SemanticGraph::Context& ctx (c.context ());
+
+ if (!ctx.count ("ordered"))
+ {
+ // First process our base.
+ //
+ if (c.inherits_p ())
+ {
+ SemanticGraph::Type& b (c.inherits ().base ());
+
+ if (!b.context ().count ("ordered"))
+ dispatch (b);
+ }
+
+ // See if our base (not necessarily immediate) is ordered.
+ //
+ using SemanticGraph::Complex;
+
+ Complex* b (0);
+
+ for (Complex* p (&c); p->inherits_p ();)
+ {
+ if ((b = dynamic_cast<Complex*> (&p->inherits ().base ())))
+ {
+ if (Context::ordered_p (*b))
+ break;
+
+ p = b;
+ }
+ else
+ break;
+ }
+
+ bool o (all_ ||
+ (derived_ && b != 0 && Context::ordered_p (*b)) ||
+ (mixed_ && c.mixed_p ()) ||
+ ordered_types_.find (c));
+ ctx.set ("ordered", o);
+
+ // Assign ids to elements and wildcards, calculate total count.
+ //
+ if (o)
+ {
+ size_t count (
+ b != 0 && Context::ordered_p (*b)
+ ? b->context ().get<size_t> ("ordered-count")
+ : 1);
+
+ ctx.set ("ordered-start", count);
+
+ Member m (count);
+ Traversal::Names n (m);
+ names (c, n);
+
+ // Assign content id for mixed text.
+ //
+ if (Context::mixed_p (c) && count == 1)
+ ctx.set ("mixed-ordered-id", m.count_++);
+
+ ctx.set ("ordered-count", m.count_);
+ }
+ }
+ }
+
+ private:
+ TypeNameSet& ordered_types_;
+ bool derived_;
+ bool mixed_;
+ bool all_;
+ };
+
+ // Go into sourced/included/imported schemas while making sure
+ // we don't process the same stuff more than once.
+ //
+ struct Uses: Traversal::Sources,
+ Traversal::Includes,
+ Traversal::Imports
+ {
+ Uses (char const* seen_key)
+ : seen_key_ (seen_key)
+ {
+ }
+
+ virtual void
+ traverse (SemanticGraph::Sources& sr)
+ {
+ SemanticGraph::Schema& s (sr.schema ());
+
+ if (!s.context ().count (seen_key_))
+ {
+ s.context ().set (seen_key_, true);
+ Traversal::Sources::traverse (sr);
+ }
+ }
+
+ virtual void
+ traverse (SemanticGraph::Includes& i)
+ {
+ SemanticGraph::Schema& s (i.schema ());
+
+ if (!s.context ().count (seen_key_))
+ {
+ s.context ().set (seen_key_, true);
+ Traversal::Includes::traverse (i);
+ }
+ }
+
+ virtual void
+ traverse (SemanticGraph::Imports& i)
+ {
+ SemanticGraph::Schema& s (i.schema ());
+
+ if (!s.context ().count (seen_key_))
+ {
+ s.context ().set (seen_key_, true);
+ Traversal::Imports::traverse (i);
+ }
+ }
+
+ private:
+ char const* seen_key_;
+ };
+
+ char const* seen_key = "cxx-tree-order-processor-seen";
+
+ bool
+ process_impl (options const& ops,
+ SemanticGraph::Schema& tu,
+ SemanticGraph::Path const&)
+ {
+ // Prepare a set of ordered types.
+ //
+ TypeNameSet ordered_types (ops.ordered_type ().begin (),
+ ops.ordered_type ().end ());
+
+ // Root schema in the file-per-type mode is just a bunch
+ // of includes without a namespace.
+ //
+ SemanticGraph::Schema::NamesIterator i (tu.names_begin ());
+
+ // Nothing to do if this is the XML Schema namespace.
+ //
+ if (i == tu.names_end () ||
+ i->named ().name () != L"http://www.w3.org/2001/XMLSchema")
+ {
+ // Note that we check first if this schema has already been
+ // processed which may happen in the file-per-type compilation
+ // mode.
+ //
+ if (!tu.context ().count (seen_key))
+ {
+ Traversal::Schema schema;
+ Uses uses (seen_key);
+
+ schema >> uses >> schema;
+
+ Traversal::Names schema_names;
+ Traversal::Namespace ns;
+ Traversal::Names ns_names;
+ Type type (ordered_types,
+ ops.ordered_type_derived (),
+ ops.ordered_type_mixed (),
+ ops.ordered_type_all ());
+
+ schema >> schema_names >> ns >> ns_names >> type;
+
+ // Some twisted schemas do recusive self-inclusion.
+ //
+ tu.context ().set (seen_key, true);
+
+ schema.dispatch (tu);
+ }
+ }
+
+ return true;
+ }
+ }
+
+ bool OrderProcessor::
+ process (options const& ops,
+ SemanticGraph::Schema& tu,
+ SemanticGraph::Path const& file)
+ {
+ return process_impl (ops, tu, file);
+ }
+ }
+}
diff --git a/xsd/xsd/cxx/tree/order-processor.hxx b/xsd/xsd/cxx/tree/order-processor.hxx
new file mode 100644
index 0000000..fa68d21
--- /dev/null
+++ b/xsd/xsd/cxx/tree/order-processor.hxx
@@ -0,0 +1,30 @@
+// file : xsde/cxx/tree/order-processor.hxx
+// copyright : Copyright (c) 2006-2014 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#ifndef CXX_TREE_ORDER_PROCESSOR_HXX
+#define CXX_TREE_ORDER_PROCESSOR_HXX
+
+#include <xsd-frontend/semantic-graph.hxx>
+
+#include <xsd.hxx>
+#include <types.hxx>
+
+#include <cxx/tree/options.hxx>
+
+namespace CXX
+{
+ namespace Tree
+ {
+ class OrderProcessor
+ {
+ public:
+ bool
+ process (options const&,
+ XSDFrontend::SemanticGraph::Schema&,
+ XSDFrontend::SemanticGraph::Path const& file);
+ };
+ }
+}
+
+#endif // CXX_TREE_ORDER_PROCESSOR_HXX
diff --git a/xsd/xsd/cxx/tree/parser-header.cxx b/xsd/xsd/cxx/tree/parser-header.cxx
index c1d1ab9..8aff44f 100644
--- a/xsd/xsd/cxx/tree/parser-header.cxx
+++ b/xsd/xsd/cxx/tree/parser-header.cxx
@@ -1,6 +1,5 @@
// file : xsd/cxx/tree/parser-header.cxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#include <cxx/tree/parser-header.hxx>
@@ -23,7 +22,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& e)
{
if (!doc_root_p (e))
@@ -71,7 +70,7 @@ namespace CXX
}
os << inst_exp
- << "::std::auto_ptr< " << type_name (e) << " >" << endl
+ << auto_ptr << "< " << type_name (e) << " >" << endl
<< name << " (const " << string_type << "& uri," << endl
<< flags_type << " f = 0," << endl
<< "const " << properties_type << "& p = " << properties_type << " ());"
@@ -94,7 +93,7 @@ namespace CXX
}
os << inst_exp
- << "::std::auto_ptr< " << type_name (e) << " >" << endl
+ << auto_ptr << "< " << type_name (e) << " >" << endl
<< name << " (const " << string_type << "& uri," << endl
<< error_handler << "& eh," << endl
<< flags_type << " f = 0," << endl
@@ -120,7 +119,7 @@ namespace CXX
}
os << inst_exp
- << "::std::auto_ptr< " << type_name (e) << " >" << endl
+ << auto_ptr << "< " << type_name (e) << " >" << endl
<< name << " (const " << string_type << "& uri," << endl
<< xerces_ns << "::DOMErrorHandler& eh," << endl
<< flags_type << " f = 0," << endl
@@ -149,7 +148,7 @@ namespace CXX
}
os << inst_exp
- << "::std::auto_ptr< " << type_name (e) << " >" << endl
+ << auto_ptr << "< " << type_name (e) << " >" << endl
<< name << " (::std::istream& is," << endl
<< flags_type << " f = 0," << endl
<< "const " << properties_type << "& p = " << properties_type << " ());"
@@ -172,7 +171,7 @@ namespace CXX
}
os << inst_exp
- << "::std::auto_ptr< " << type_name (e) << " >" << endl
+ << auto_ptr << "< " << type_name (e) << " >" << endl
<< name << " (::std::istream& is," << endl
<< error_handler << "& eh," << endl
<< flags_type << " f = 0," << endl
@@ -198,7 +197,7 @@ namespace CXX
}
os << inst_exp
- << "::std::auto_ptr< " << type_name (e) << " >" << endl
+ << auto_ptr << "< " << type_name (e) << " >" << endl
<< name << " (::std::istream& is," << endl
<< xerces_ns << "::DOMErrorHandler& eh," << endl
<< flags_type << " f = 0," << endl
@@ -225,7 +224,7 @@ namespace CXX
}
os << inst_exp
- << "::std::auto_ptr< " << type_name (e) << " >" << endl
+ << auto_ptr << "< " << type_name (e) << " >" << endl
<< name << " (::std::istream& is," << endl
<< "const " << string_type << "& id," << endl
<< flags_type << " f = 0," << endl
@@ -256,7 +255,7 @@ namespace CXX
}
os << inst_exp
- << "::std::auto_ptr< " << type_name (e) << " >" << endl
+ << auto_ptr << "< " << type_name (e) << " >" << endl
<< name << " (::std::istream& is," << endl
<< "const " << string_type << "& id," << endl
<< error_handler << "& eh," << endl
@@ -288,7 +287,7 @@ namespace CXX
}
os << inst_exp
- << "::std::auto_ptr< " << type_name (e) << " >" << endl
+ << auto_ptr << "< " << type_name (e) << " >" << endl
<< name << " (::std::istream& is," << endl
<< "const " << string_type << "& id," << endl
<< xerces_ns << "::DOMErrorHandler& eh," << endl
@@ -318,7 +317,7 @@ namespace CXX
}
os << inst_exp
- << "::std::auto_ptr< " << type_name (e) << " >" << endl
+ << auto_ptr << "< " << type_name (e) << " >" << endl
<< name << " (" << xerces_ns << "::InputSource& is," << endl
<< flags_type << " f = 0," << endl
<< "const " << properties_type << "& p = " << properties_type << " ());"
@@ -342,7 +341,7 @@ namespace CXX
}
os << inst_exp
- << "::std::auto_ptr< " << type_name (e) << " >" << endl
+ << auto_ptr << "< " << type_name (e) << " >" << endl
<< name << " (" << xerces_ns << "::InputSource& is," << endl
<< error_handler << "& eh," << endl
<< flags_type << " f = 0," << endl
@@ -368,7 +367,7 @@ namespace CXX
}
os << inst_exp
- << "::std::auto_ptr< " << type_name (e) << " >" << endl
+ << auto_ptr << "< " << type_name (e) << " >" << endl
<< name << " (" << xerces_ns << "::InputSource& is," << endl
<< xerces_ns << "::DOMErrorHandler& eh," << endl
<< flags_type << " f = 0," << endl
@@ -395,7 +394,7 @@ namespace CXX
}
os << inst_exp
- << "::std::auto_ptr< " << type_name (e) << " >" << endl
+ << auto_ptr << "< " << type_name (e) << " >" << endl
<< name << " (const " << xerces_ns << "::DOMDocument& d," << endl
<< flags_type << " f = 0," << endl
<< "const " << properties_type << "& p = " << properties_type << " ());"
@@ -420,9 +419,9 @@ namespace CXX
}
os << inst_exp
- << "::std::auto_ptr< " << type_name (e) << " >" << endl
+ << auto_ptr << "< " << type_name (e) << " >" << endl
<< name << " (" << dom_auto_ptr << "< " << xerces_ns <<
- "::DOMDocument >& d," << endl
+ "::DOMDocument > d," << endl
<< flags_type << " f = 0," << endl
<< "const " << properties_type << "& p = " << properties_type << " ());"
<< endl;
@@ -449,7 +448,7 @@ namespace CXX
}
- Void
+ void
generate_parser_header (Context& ctx)
{
ctx.os << "#include <iosfwd>" << endl
@@ -460,7 +459,7 @@ namespace CXX
<< endl;
Traversal::Schema schema;
- Traversal::Sources sources;
+ Sources sources;
Traversal::Names names_ns, names;
Namespace ns (ctx);
ElementFunction element (ctx);
diff --git a/xsd/xsd/cxx/tree/parser-header.hxx b/xsd/xsd/cxx/tree/parser-header.hxx
index 20ca7d4..dfe7843 100644
--- a/xsd/xsd/cxx/tree/parser-header.hxx
+++ b/xsd/xsd/cxx/tree/parser-header.hxx
@@ -1,6 +1,5 @@
// file : xsd/cxx/tree/parser-header.hxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#ifndef CXX_TREE_PARSER_HEADER_HXX
@@ -13,7 +12,7 @@ namespace CXX
{
namespace Tree
{
- Void
+ void
generate_parser_header (Context&);
}
}
diff --git a/xsd/xsd/cxx/tree/parser-source.cxx b/xsd/xsd/cxx/tree/parser-source.cxx
index 7291cb8..c93368c 100644
--- a/xsd/xsd/cxx/tree/parser-source.cxx
+++ b/xsd/xsd/cxx/tree/parser-source.cxx
@@ -1,6 +1,5 @@
// file : xsd/cxx/tree/parser-source.cxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#include <cxx/tree/parser-source.hxx>
@@ -23,7 +22,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& e)
{
if (!doc_root_p (e))
@@ -38,9 +37,11 @@ namespace CXX
// confused if the name is 'type'. (see tests/schema/anonymous)
//
+ char const* d (std >= cxx_version::cxx11 ? "std::move (d)" : "d");
+
// URI.
//
- os << "::std::auto_ptr< " << type << " >" << endl
+ os << auto_ptr << "< " << type << " >" << endl
<< name << " (const " << string_type << "& u," << endl
<< flags_type << " f," << endl
<< "const " << properties_type << "& p)"
@@ -56,22 +57,20 @@ namespace CXX
<< "::xsd::cxx::xml::dom::parse< " << char_type << " > (" << endl
<< "u, h, p, f";
- if (options.value<CLI::disable_multi_import> ())
+ if (options.disable_multi_import ())
os << " | ::xsd::cxx::xml::dom::no_muliple_imports";
- os << "));"
+ os << "));"
<< endl
<< "h.throw_if_failed< ::xsd::cxx::tree::parsing< " <<
char_type << " > > ();"
<< endl
- << "::std::auto_ptr< " << type << " > r (" << endl
+ << "return " << auto_ptr << "< " << type << " > (" << endl
<< fq_name (e, "parser") << " (" << endl
- << "d, f | " << flags_type << "::own_dom, p));"
- << endl
- << "return r;"
+ << d << ", f | " << flags_type << "::own_dom, p));"
<< "}";
- os << "::std::auto_ptr< " << type << " >" << endl
+ os << auto_ptr << "< " << type << " >" << endl
<< name << " (const " << string_type << "& u," << endl
<< error_handler << "& h," << endl
<< flags_type << " f," << endl
@@ -86,7 +85,7 @@ namespace CXX
<< "::xsd::cxx::xml::dom::parse< " << char_type << " > (" << endl
<< "u, h, p, f";
- if (options.value<CLI::disable_multi_import> ())
+ if (options.disable_multi_import ())
os << " | ::xsd::cxx::xml::dom::no_muliple_imports";
os << "));"
@@ -94,14 +93,12 @@ namespace CXX
<< "if (!d.get ())" << endl
<< "throw ::xsd::cxx::tree::parsing< " << char_type << " > ();"
<< endl
- << "::std::auto_ptr< " << type << " > r (" << endl
+ << "return " << auto_ptr << "< " << type << " > (" << endl
<< fq_name (e, "parser") << " (" << endl
- << "d, f | " << flags_type << "::own_dom, p));"
- << endl
- << "return r;"
+ << d << ", f | " << flags_type << "::own_dom, p));"
<< "}";
- os << "::std::auto_ptr< " << type << " >" << endl
+ os << auto_ptr << "< " << type << " >" << endl
<< name << " (const " << string_type << "& u," << endl
<< xerces_ns << "::DOMErrorHandler& h," << endl
<< flags_type << " f," << endl
@@ -112,7 +109,7 @@ namespace CXX
<< "::xsd::cxx::xml::dom::parse< " << char_type << " > (" << endl
<< "u, h, p, f";
- if (options.value<CLI::disable_multi_import> ())
+ if (options.disable_multi_import ())
os << " | ::xsd::cxx::xml::dom::no_muliple_imports";
os << "));"
@@ -120,17 +117,15 @@ namespace CXX
<< "if (!d.get ())" << endl
<< "throw ::xsd::cxx::tree::parsing< " << char_type << " > ();"
<< endl
- << "::std::auto_ptr< " << type << " > r (" << endl
+ << "return " << auto_ptr << "< " << type << " > (" << endl
<< fq_name (e, "parser") << " (" << endl
- << "d, f | " << flags_type << "::own_dom, p));"
- << endl
- << "return r;"
+ << d << ", f | " << flags_type << "::own_dom, p));"
<< "}";
// istream
//
- os << "::std::auto_ptr< " << type << " >" << endl
+ os << auto_ptr << "< " << type << " >" << endl
<< name << " (::std::istream& is," << endl
<< flags_type << " f," << endl
<< "const " << properties_type << "& p)"
@@ -143,7 +138,7 @@ namespace CXX
<< "return " << fq_name (e, "parser") << " (isrc, f, p);"
<< "}";
- os << "::std::auto_ptr< " << type << " >" << endl
+ os << auto_ptr << "< " << type << " >" << endl
<< name << " (::std::istream& is," << endl
<< error_handler << "& h," << endl
<< flags_type << " f," << endl
@@ -157,7 +152,7 @@ namespace CXX
<< "return " << fq_name (e, "parser") << " (isrc, h, f, p);"
<< "}";
- os << "::std::auto_ptr< " << type << " >" << endl
+ os << auto_ptr << "< " << type << " >" << endl
<< name << " (::std::istream& is," << endl
<< xerces_ns << "::DOMErrorHandler& h," << endl
<< flags_type << " f," << endl
@@ -167,7 +162,7 @@ namespace CXX
<< "return " << fq_name (e, "parser") << " (isrc, h, f, p);"
<< "}";
- os << "::std::auto_ptr< " << type << " >" << endl
+ os << auto_ptr << "< " << type << " >" << endl
<< name << " (::std::istream& is," << endl
<< "const " << string_type << "& sid," << endl
<< flags_type << " f," << endl
@@ -181,7 +176,7 @@ namespace CXX
<< "return " << fq_name (e, "parser") << " (isrc, f, p);"
<< "}";
- os << "::std::auto_ptr< " << type << " >" << endl
+ os << auto_ptr << "< " << type << " >" << endl
<< name << " (::std::istream& is," << endl
<< "const " << string_type << "& sid," << endl
<< error_handler << "& h," << endl
@@ -196,7 +191,7 @@ namespace CXX
<< "return " << fq_name (e, "parser") << " (isrc, h, f, p);"
<< "}";
- os << "::std::auto_ptr< " << type << " >" << endl
+ os << auto_ptr << "< " << type << " >" << endl
<< name << " (::std::istream& is," << endl
<< "const " << string_type << "& sid," << endl
<< xerces_ns << "::DOMErrorHandler& h," << endl
@@ -210,7 +205,7 @@ namespace CXX
// InputSource.
//
- os << "::std::auto_ptr< " << type << " >" << endl
+ os << auto_ptr << "< " << type << " >" << endl
<< name << " (" << xerces_ns << "::InputSource& i," << endl
<< flags_type << " f," << endl
<< "const " << properties_type << "& p)"
@@ -222,7 +217,7 @@ namespace CXX
<< "::xsd::cxx::xml::dom::parse< " << char_type << " > (" << endl
<< "i, h, p, f";
- if (options.value<CLI::disable_multi_import> ())
+ if (options.disable_multi_import ())
os << " | ::xsd::cxx::xml::dom::no_muliple_imports";
os << "));"
@@ -230,14 +225,12 @@ namespace CXX
<< "h.throw_if_failed< ::xsd::cxx::tree::parsing< " <<
char_type << " > > ();"
<< endl
- << "::std::auto_ptr< " << type << " > r (" << endl
+ << "return " << auto_ptr << "< " << type << " > (" << endl
<< fq_name (e, "parser") << " (" << endl
- << "d, f | " << flags_type << "::own_dom, p));"
- << endl
- << "return r;"
+ << d << ", f | " << flags_type << "::own_dom, p));"
<< "}";
- os << "::std::auto_ptr< " << type << " >" << endl
+ os << auto_ptr << "< " << type << " >" << endl
<< name << " (" << xerces_ns << "::InputSource& i," << endl
<< error_handler << "& h," << endl
<< flags_type << " f," << endl
@@ -248,7 +241,7 @@ namespace CXX
<< "::xsd::cxx::xml::dom::parse< " << char_type << " > (" << endl
<< "i, h, p, f";
- if (options.value<CLI::disable_multi_import> ())
+ if (options.disable_multi_import ())
os << " | ::xsd::cxx::xml::dom::no_muliple_imports";
os << "));"
@@ -256,15 +249,13 @@ namespace CXX
<< "if (!d.get ())" << endl
<< "throw ::xsd::cxx::tree::parsing< " << char_type << " > ();"
<< endl
- << "::std::auto_ptr< " << type << " > r (" << endl
+ << "return " << auto_ptr << "< " << type << " > (" << endl
<< fq_name (e, "parser") << " (" << endl
- << "d, f | " << flags_type << "::own_dom, p));"
- << endl
- << "return r;"
+ << d << ", f | " << flags_type << "::own_dom, p));"
<< "}";
- os << "::std::auto_ptr< " << type << " >" << endl
+ os << auto_ptr << "< " << type << " >" << endl
<< name << " (" << xerces_ns << "::InputSource& i," << endl
<< xerces_ns << "::DOMErrorHandler& h," << endl
<< flags_type << " f," << endl
@@ -275,7 +266,7 @@ namespace CXX
<< "::xsd::cxx::xml::dom::parse< " << char_type << " > (" << endl
<< "i, h, p, f";
- if (options.value<CLI::disable_multi_import> ())
+ if (options.disable_multi_import ())
os << " | ::xsd::cxx::xml::dom::no_muliple_imports";
os << "));"
@@ -283,18 +274,16 @@ namespace CXX
<< "if (!d.get ())" << endl
<< "throw ::xsd::cxx::tree::parsing< " << char_type << " > ();"
<< endl
- << "::std::auto_ptr< " << type << " > r (" << endl
+ << "return " << auto_ptr << "< " << type << " > (" << endl
<< fq_name (e, "parser") << " (" << endl
- << "d, f | " << flags_type << "::own_dom, p));"
- << endl
- << "return r;"
+ << d << ", f | " << flags_type << "::own_dom, p));"
<< "}";
// DOM.
//
- Boolean fund (false);
+ bool fund (false);
{
IsFundamentalType test (fund);
test.dispatch (t);
@@ -304,44 +293,36 @@ namespace CXX
// If this element's type is anonymous then we don't need to do
// anything.
//
- Boolean poly (polymorphic && polymorphic_p (t) && !anonymous_p (t));
+ bool poly (polymorphic && polymorphic_p (t) && !anonymous_p (t));
// const DOMDocument&
//
- os << "::std::auto_ptr< " << type << " >" << endl
- << name << " (const " << xerces_ns << "::DOMDocument& d," << endl
+ os << auto_ptr << "< " << type << " >" << endl
+ << name << " (const " << xerces_ns << "::DOMDocument& doc," << endl
<< flags_type << " f," << endl
<< "const " << properties_type << "& p)"
<< "{"
<< "if (f & " << flags_type << "::keep_dom)"
<< "{"
<< dom_auto_ptr << "< " << xerces_ns <<
- "::DOMDocument > c (" << endl
+ "::DOMDocument > d (" << endl
<< "static_cast< " << xerces_ns <<
- "::DOMDocument* > (d.cloneNode (true)));"
+ "::DOMDocument* > (doc.cloneNode (true)));"
<< endl
- << "::std::auto_ptr< " << type << " > r (" << endl
+ << "return " << auto_ptr << "< " << type << " > (" << endl
<< fq_name (e, "parser") << " (" << endl
- << "c, f | " << flags_type << "::own_dom, p));"
- << endl
- << "return r;"
+ << d << ", f | " << flags_type << "::own_dom, p));"
<< "}"
- << "const " << xerces_ns << "::DOMElement& e (*d.getDocumentElement ());"
+ << "const " << xerces_ns << "::DOMElement& e (*doc.getDocumentElement ());"
<< "const " << qname_type << " n (" << endl
<< "::xsd::cxx::xml::dom::name< " << char_type << " > (e));"
<< endl;
if (poly)
{
- // aCC cannot handle an inline call to type_factory_map_instance.
- //
- os << "::xsd::cxx::tree::type_factory_map< " << char_type <<
- " >& tfm (" << endl
- << "::xsd::cxx::tree::type_factory_map_instance< 0, " <<
- char_type << " > ());"
- << endl
- << "::std::auto_ptr< ::xsd::cxx::tree::type > tmp (" << endl
- << "tfm.create (" << endl
+ os << auto_ptr << "< ::xsd::cxx::tree::type > tmp (" << endl
+ << "::xsd::cxx::tree::type_factory_map_instance< " <<
+ poly_plate << ", " << char_type << " > ().create (" << endl
<< strlit (e.name ()) << "," << endl
<< strlit (e.namespace_().name ()) << "," << endl
<< "&::xsd::cxx::tree::factory_impl< " << type << " >," << endl
@@ -349,7 +330,7 @@ namespace CXX
<< endl
<< "if (tmp.get () != 0)"
<< "{"
- << "::std::auto_ptr< " << type << " > r (" << endl
+ << auto_ptr << "< " << type << " > r (" << endl
<< "dynamic_cast< " << type << "* > (tmp.get ()));"
<< endl
<< "if (r.get ())" << endl
@@ -367,7 +348,7 @@ namespace CXX
if (fund)
{
- os << "::std::auto_ptr< " << type << " > r (" << endl
+ os << auto_ptr << "< " << type << " > r (" << endl
<< "new " << type << " (" << endl
<< "::xsd::cxx::tree::traits< " << type << ", " <<
char_type;
@@ -382,7 +363,7 @@ namespace CXX
}
else
{
- os << "::std::auto_ptr< " << type << " > r (" << endl
+ os << auto_ptr << "< " << type << " > r (" << endl
<< "::xsd::cxx::tree::traits< " << type << ", " <<
char_type << " >::create (" << endl
<< "e, f, 0));";
@@ -400,11 +381,11 @@ namespace CXX
<< "}";
- // dom::auto_ptr<DOMDocument>
+ // dom::auto_ptr/unique_ptr<DOMDocument>
//
- os << "::std::auto_ptr< " << type << " >" << endl
+ os << auto_ptr << "< " << type << " >" << endl
<< name << " (" << dom_auto_ptr << "< " << xerces_ns <<
- "::DOMDocument >& d," << endl
+ "::DOMDocument > d," << endl
<< flags_type << " f," << endl
<< "const " << properties_type << "&)"
<< "{"
@@ -431,15 +412,9 @@ namespace CXX
if (poly)
{
- // aCC cannot handle an inline call to type_factory_map_instance.
- //
- os << "::xsd::cxx::tree::type_factory_map< " << char_type <<
- " >& tfm (" << endl
- << "::xsd::cxx::tree::type_factory_map_instance< 0, " <<
- char_type << " > ());"
- << endl
- << "::std::auto_ptr< ::xsd::cxx::tree::type > tmp (" << endl
- << "tfm.create (" << endl
+ os << auto_ptr << "< ::xsd::cxx::tree::type > tmp (" << endl
+ << "::xsd::cxx::tree::type_factory_map_instance< " <<
+ poly_plate << ", " << char_type << " > ().create (" << endl
<< strlit (e.name ()) << "," << endl
<< strlit (e.namespace_().name ()) << "," << endl
<< "&::xsd::cxx::tree::factory_impl< " << type << " >," << endl
@@ -456,7 +431,7 @@ namespace CXX
if (fund)
{
- os << "::std::auto_ptr< " << type << " > r (" << endl
+ os << auto_ptr << "< " << type << " > r (" << endl
<< "new " << type << " (" << endl
<< "::xsd::cxx::tree::traits< " << type << ", " <<
char_type;
@@ -471,7 +446,7 @@ namespace CXX
}
else
{
- os << "::std::auto_ptr< " << type << " > r (" << endl
+ os << auto_ptr << "< " << type << " > r (" << endl
<< "::xsd::cxx::tree::traits< " << type << ", " <<
char_type << " >::create (" << endl
<< "e, f, 0));";
@@ -481,7 +456,7 @@ namespace CXX
if (poly)
{
os << endl
- << "::std::auto_ptr< " << type << " > r (" << endl
+ << auto_ptr << "< " << type << " > r (" << endl
<< "dynamic_cast< " << type << "* > (tmp.get ()));"
<< endl
<< "if (r.get ())" << endl
@@ -517,10 +492,8 @@ namespace CXX
};
}
- Void
- generate_parser_source (Context& ctx,
- UnsignedLong first,
- UnsignedLong last)
+ void
+ generate_parser_source (Context& ctx, size_t first, size_t last)
{
ctx.os << "#include <istream>" << endl
<< "#include <xsd/cxx/xml/sax/std-input-source.hxx>" << endl
@@ -528,7 +501,7 @@ namespace CXX
<< endl;
Traversal::Schema schema;
- Traversal::Sources sources;
+ Sources sources;
Traversal::Names names_ns, names;
Namespace ns (ctx, first, last);
ElementFunction element (ctx);
diff --git a/xsd/xsd/cxx/tree/parser-source.hxx b/xsd/xsd/cxx/tree/parser-source.hxx
index 2a85571..a5cd597 100644
--- a/xsd/xsd/cxx/tree/parser-source.hxx
+++ b/xsd/xsd/cxx/tree/parser-source.hxx
@@ -1,6 +1,5 @@
// file : xsd/cxx/tree/parser-source.hxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#ifndef CXX_TREE_PARSER_SOURCE_HXX
@@ -12,8 +11,8 @@ namespace CXX
{
namespace Tree
{
- Void
- generate_parser_source (Context&, UnsignedLong first, UnsignedLong last);
+ void
+ generate_parser_source (Context&, size_t first, size_t last);
}
}
diff --git a/xsd/xsd/cxx/tree/polymorphism-processor.cxx b/xsd/xsd/cxx/tree/polymorphism-processor.cxx
index 0763f0f..cbd2471 100644
--- a/xsd/xsd/cxx/tree/polymorphism-processor.cxx
+++ b/xsd/xsd/cxx/tree/polymorphism-processor.cxx
@@ -1,19 +1,16 @@
// file : xsde/cxx/tree/polymorphism-processor.cxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2006-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2006-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+#include <iostream>
+
#include <cxx/tree/elements.hxx>
#include <cxx/tree/polymorphism-processor.hxx>
#include <xsd-frontend/semantic-graph.hxx>
#include <xsd-frontend/traversal.hxx>
-#include <cult/containers/set.hxx>
-
-#include <iostream>
-
-using std::wcerr;
+using namespace std;
namespace CXX
{
@@ -21,64 +18,17 @@ namespace CXX
{
namespace
{
- struct TypeSet
- {
- template <typename I>
- TypeSet (I begin, I end)
- {
- for (; begin != end; ++begin)
- insert (*begin);
- }
-
- Void
- insert (String const& name)
- {
- Size p (name.rfind ('#'));
-
- if (p == String::npos)
- unames_.insert (name);
- else
- qnames_.insert (name);
- }
-
- Boolean
- find (SemanticGraph::Type& t)
- {
- if (!unames_.empty ())
- {
- if (unames_.find (t.name ()) != unames_.end ())
- return true;
- }
-
- if (!qnames_.empty ())
- {
- if (qnames_.find (t.scope ().name () + L"#" + t.name ()) !=
- qnames_.end ())
- return true;
- }
-
- return false;
- }
-
- private:
- typedef Cult::Containers::Set<String> StringSet;
-
- StringSet unames_;
- StringSet qnames_;
- };
-
-
//
//
struct Type: Traversal::Type,
Traversal::Complex
{
- Type (TypeSet& poly_types)
+ Type (TypeNameSet& poly_types)
: poly_types_ (poly_types)
{
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Type& t)
{
SemanticGraph::Context& ctx (t.context ());
@@ -87,7 +37,7 @@ namespace CXX
ctx.set ("polymorphic", poly_types_.find (t));
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Complex& c)
{
SemanticGraph::Context& ctx (c.context ());
@@ -96,7 +46,7 @@ namespace CXX
{
// First check our base.
//
- Boolean pb (false);
+ bool pb (false);
if (c.inherits_p ())
{
SemanticGraph::Type& b (c.inherits ().base ());
@@ -104,7 +54,7 @@ namespace CXX
if (!b.context ().count ("polymorphic"))
dispatch (b);
- pb = b.context ().get<Boolean> ("polymorphic");
+ pb = b.context ().get<bool> ("polymorphic");
}
ctx.set ("polymorphic", pb || poly_types_.find (c));
@@ -112,7 +62,7 @@ namespace CXX
}
private:
- TypeSet& poly_types_;
+ TypeNameSet& poly_types_;
};
struct FundType: Traversal::AnyType,
@@ -171,13 +121,13 @@ namespace CXX
Traversal::Fundamental::Entity,
Traversal::Fundamental::Entities
{
- FundType (TypeSet& poly_types, Boolean& valid)
+ FundType (TypeNameSet& poly_types, bool& valid)
: poly_types_ (poly_types), valid_ (valid)
{
}
- Void
- check (SemanticGraph::Type& t, Boolean fund)
+ void
+ check (SemanticGraph::Type& t, bool fund)
{
SemanticGraph::Context& ctx (t.context ());
@@ -201,13 +151,13 @@ namespace CXX
// anyType & anySimpleType.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::AnyType& t)
{
check (t, false);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::AnySimpleType& t)
{
check (t, false);
@@ -215,7 +165,7 @@ namespace CXX
// Boolean.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Boolean& t)
{
check (t, true);
@@ -223,79 +173,79 @@ namespace CXX
// Integral types.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Byte& t)
{
check (t, true);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::UnsignedByte& t)
{
check (t, true);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Short& t)
{
check (t, true);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::UnsignedShort& t)
{
check (t, true);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Int& t)
{
check (t, true);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::UnsignedInt& t)
{
check (t, true);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Long& t)
{
check (t, true);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::UnsignedLong& t)
{
check (t, true);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Integer& t)
{
check (t, true);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NonPositiveInteger& t)
{
check (t, true);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NonNegativeInteger& t)
{
check (t, true);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::PositiveInteger& t)
{
check (t, true);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NegativeInteger& t)
{
check (t, true);
@@ -303,19 +253,19 @@ namespace CXX
// Floats.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Float& t)
{
check (t, true);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Double& t)
{
check (t, true);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Decimal& t)
{
check (t, true);
@@ -323,49 +273,49 @@ namespace CXX
// Strings.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::String& t)
{
check (t, false);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NormalizedString& t)
{
check (t, false);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Token& t)
{
check (t, false);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NameToken& t)
{
check (t, false);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NameTokens& t)
{
check (t, false);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Name& t)
{
check (t, false);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::NCName& t)
{
check (t, false);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Language& t)
{
check (t, false);
@@ -374,7 +324,7 @@ namespace CXX
// Qualified name.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::QName& t)
{
check (t, false);
@@ -383,19 +333,19 @@ namespace CXX
// ID/IDREF.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Id& t)
{
check (t, false);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::IdRef& t)
{
check (t, false);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::IdRefs& t)
{
check (t, false);
@@ -403,7 +353,7 @@ namespace CXX
// URI.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::AnyURI& t)
{
check (t, false);
@@ -411,13 +361,13 @@ namespace CXX
// Binary.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Base64Binary& t)
{
check (t, false);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::HexBinary& t)
{
check (t, false);
@@ -426,55 +376,55 @@ namespace CXX
// Date/time.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Date& t)
{
check (t, false);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::DateTime& t)
{
check (t, false);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Duration& t)
{
check (t, false);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Day& t)
{
check (t, false);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Month& t)
{
check (t, false);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::MonthDay& t)
{
check (t, false);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Year& t)
{
check (t, false);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::YearMonth& t)
{
check (t, false);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Time& t)
{
check (t, false);
@@ -482,27 +432,27 @@ namespace CXX
// Entity.
//
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Entity& t)
{
check (t, false);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Entities& t)
{
check (t, false);
}
private:
- TypeSet& poly_types_;
- Boolean& valid_;
+ TypeNameSet& poly_types_;
+ bool& valid_;
};
struct GlobalElement: Traversal::Element
{
- GlobalElement (TypeSet& poly_types,
- Boolean& valid,
+ GlobalElement (TypeNameSet& poly_types,
+ bool& valid,
const WarningSet& disabled_warnings)
: poly_types_ (poly_types), valid_ (valid), warning_ (true)
{
@@ -511,7 +461,7 @@ namespace CXX
warning_ = false;
}
- virtual Void
+ virtual void
traverse (Type& e)
{
using SemanticGraph::Schema;
@@ -528,13 +478,13 @@ namespace CXX
// We may need to override the previous value.
//
- if (ctx.count ("polymorphic") && ctx.get<Boolean> ("polymorphic"))
+ if (ctx.count ("polymorphic") && ctx.get<bool> ("polymorphic"))
return;
// Built-in types that are mapped to fundamental types cannot
// be declared polymorphic.
//
- Boolean fund (false);
+ bool fund (false);
IsFundamentalType test (fund);
test.dispatch (rt);
@@ -585,7 +535,7 @@ namespace CXX
private:
// Return true if root sources s.
//
- Boolean
+ bool
sources_p (SemanticGraph::Schema& root, SemanticGraph::Schema& s)
{
using SemanticGraph::Schema;
@@ -605,9 +555,9 @@ namespace CXX
}
private:
- TypeSet& poly_types_;
- Boolean& valid_;
- Boolean warning_;
+ TypeNameSet& poly_types_;
+ bool& valid_;
+ bool warning_;
};
// Go into sourced/included/imported schemas while making sure
@@ -617,12 +567,12 @@ namespace CXX
Traversal::Includes,
Traversal::Imports
{
- Uses (Char const* seen_key)
+ Uses (char const* seen_key)
: seen_key_ (seen_key)
{
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Sources& sr)
{
SemanticGraph::Schema& s (sr.schema ());
@@ -634,7 +584,7 @@ namespace CXX
}
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Includes& i)
{
SemanticGraph::Schema& s (i.schema ());
@@ -646,7 +596,7 @@ namespace CXX
}
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Imports& i)
{
SemanticGraph::Schema& s (i.schema ());
@@ -659,25 +609,25 @@ namespace CXX
}
private:
- Char const* seen_key_;
+ char const* seen_key_;
};
- Char const* pass_one_key = "cxx-tree-polymorphism-processor-seen-one";
- Char const* pass_two_key = "cxx-tree-polymorphism-processor-seen-two";
+ char const* pass_one_key = "cxx-tree-polymorphism-processor-seen-one";
+ char const* pass_two_key = "cxx-tree-polymorphism-processor-seen-two";
- Boolean
- process_impl (CLI::Options const& ops,
+ bool
+ process_impl (options const& ops,
SemanticGraph::Schema& tu,
SemanticGraph::Path const&,
const WarningSet& disabled_warnings)
{
- Boolean valid (true);
+ bool valid (true);
// Prepare a set of polymorphic types.
//
- TypeSet poly_types (ops.value<CLI::polymorphic_type> ().begin (),
- ops.value<CLI::polymorphic_type> ().end ());
+ TypeNameSet poly_types (ops.polymorphic_type ().begin (),
+ ops.polymorphic_type ().end ());
// Root schema in the file-per-type mode is just a bunch
// of includes without a namespace.
@@ -779,8 +729,8 @@ namespace CXX
}
}
- Boolean PolymorphismProcessor::
- process (CLI::Options const& ops,
+ bool PolymorphismProcessor::
+ process (options const& ops,
SemanticGraph::Schema& tu,
SemanticGraph::Path const& file,
const WarningSet& disabled_warnings)
diff --git a/xsd/xsd/cxx/tree/polymorphism-processor.hxx b/xsd/xsd/cxx/tree/polymorphism-processor.hxx
index 3fbeca8..7338790 100644
--- a/xsd/xsd/cxx/tree/polymorphism-processor.hxx
+++ b/xsd/xsd/cxx/tree/polymorphism-processor.hxx
@@ -1,30 +1,26 @@
// file : xsde/cxx/tree/polymorphism-processor.hxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2006-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2006-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#ifndef CXX_TREE_POLYMORPHISM_PROCESSOR_HXX
#define CXX_TREE_POLYMORPHISM_PROCESSOR_HXX
-#include <cult/types.hxx>
-
#include <xsd-frontend/semantic-graph.hxx>
-#include <cxx/tree/cli.hxx>
-
#include <xsd.hxx>
+#include <types.hxx>
+
+#include <cxx/tree/options.hxx>
namespace CXX
{
namespace Tree
{
- using namespace Cult::Types;
-
class PolymorphismProcessor
{
public:
- Boolean
- process (CLI::Options const& options,
+ bool
+ process (options const&,
XSDFrontend::SemanticGraph::Schema&,
XSDFrontend::SemanticGraph::Path const& file,
const WarningSet& disabled_warnings);
diff --git a/xsd/xsd/cxx/tree/serialization-header.cxx b/xsd/xsd/cxx/tree/serialization-header.cxx
index d024a38..67da857 100644
--- a/xsd/xsd/cxx/tree/serialization-header.cxx
+++ b/xsd/xsd/cxx/tree/serialization-header.cxx
@@ -1,6 +1,5 @@
// file : xsd/cxx/tree/serialization-header.cxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#include <cxx/tree/serialization-header.hxx>
@@ -21,7 +20,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& l)
{
String name (ename (l));
@@ -67,7 +66,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& u)
{
String name (ename (u));
@@ -112,7 +111,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& e)
{
String name (ename (e));
@@ -156,7 +155,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& c)
{
String name (ename (c));
@@ -175,7 +174,7 @@ namespace CXX
"const " << name << "&);"
<< endl;
- Boolean simple (true);
+ bool simple (true);
{
IsSimpleType t (simple);
t.dispatch (c);
@@ -211,7 +210,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& e)
{
if (doc_root_p (e))
@@ -237,7 +236,7 @@ namespace CXX
}
- virtual Void
+ virtual void
traverse (Type& e)
{
if (!doc_root_p (e))
@@ -533,10 +532,10 @@ namespace CXX
}
- Void
+ void
generate_serialization_header (Context& ctx)
{
- Boolean elemen_type (ctx.options.value<CLI::generate_element_type> ());
+ bool elemen_type (ctx.options.generate_element_type ());
if (!elemen_type)
ctx.os << "#include <iosfwd>" << endl
@@ -550,7 +549,7 @@ namespace CXX
Traversal::Schema schema;
- Traversal::Sources sources;
+ Sources sources;
Traversal::Names names_ns, names;
Namespace ns (ctx);
diff --git a/xsd/xsd/cxx/tree/serialization-header.hxx b/xsd/xsd/cxx/tree/serialization-header.hxx
index 86c6b6a..979bb2e 100644
--- a/xsd/xsd/cxx/tree/serialization-header.hxx
+++ b/xsd/xsd/cxx/tree/serialization-header.hxx
@@ -1,6 +1,5 @@
// file : xsd/cxx/tree/serialization-header.hxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#ifndef CXX_TREE_SERIALIZATION_HEADER_HXX
@@ -12,7 +11,7 @@ namespace CXX
{
namespace Tree
{
- Void
+ void
generate_serialization_header (Context&);
}
}
diff --git a/xsd/xsd/cxx/tree/serialization-source.cxx b/xsd/xsd/cxx/tree/serialization-source.cxx
index 40ae031..559a3cf 100644
--- a/xsd/xsd/cxx/tree/serialization-source.cxx
+++ b/xsd/xsd/cxx/tree/serialization-source.cxx
@@ -1,6 +1,5 @@
// file : xsd/cxx/tree/serialization-source.cxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#include <cxx/tree/serialization-source.hxx>
@@ -42,7 +41,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& l)
{
String name (ename (l));
@@ -91,7 +90,9 @@ namespace CXX
<< "l << static_cast< const " << base << "& > (i);"
<< "}";
- // Register with type factory map.
+ // Register with type factory map. If this type is anonymous
+ // but substitutes, then it will be registered as part of the
+ // substitution registration.
//
if (polymorphic && polymorphic_p (l) && !anonymous_p (l))
{
@@ -100,8 +101,8 @@ namespace CXX
String const& name (ename (l));
os << "static" << endl
- << "const ::xsd::cxx::tree::type_serializer_initializer< 0, " <<
- char_type << ", " << name << " >" << endl
+ << "const ::xsd::cxx::tree::type_serializer_initializer< " <<
+ poly_plate << ", " << char_type << ", " << name << " >" << endl
<< "_xsd_" << name << "_type_serializer_init (" << endl
<< strlit (l.name ()) << "," << endl
<< strlit (xml_ns_name (l)) << ");"
@@ -131,7 +132,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& u)
{
String name (ename (u));
@@ -171,7 +172,9 @@ namespace CXX
<< "l << static_cast< const " << base << "& > (i);"
<< "}";
- // Register with type factory map.
+ // Register with type factory map. If this type is anonymous
+ // but substitutes, then it will be registered as part of the
+ // substitution registration.
//
if (polymorphic && polymorphic_p (u) && !anonymous_p (u))
{
@@ -180,8 +183,8 @@ namespace CXX
String const& name (ename (u));
os << "static" << endl
- << "const ::xsd::cxx::tree::type_serializer_initializer< 0, " <<
- char_type << ", " << name << " >" << endl
+ << "const ::xsd::cxx::tree::type_serializer_initializer< " <<
+ poly_plate << ", " << char_type << ", " << name << " >" << endl
<< "_xsd_" << name << "_type_serializer_init (" << endl
<< strlit (u.name ()) << "," << endl
<< strlit (xml_ns_name (u)) << ");"
@@ -200,7 +203,7 @@ namespace CXX
inherits_base_ >> base_;
}
- virtual Void
+ virtual void
traverse (Type& e)
{
String name (ename (e));
@@ -253,7 +256,9 @@ namespace CXX
<< "}";
- // Register with type factory map.
+ // Register with type factory map. If this type is anonymous
+ // but substitutes, then it will be registered as part of the
+ // substitution registration.
//
if (polymorphic && polymorphic_p (e) && !anonymous_p (e))
{
@@ -262,8 +267,8 @@ namespace CXX
String const& name (ename (e));
os << "static" << endl
- << "const ::xsd::cxx::tree::type_serializer_initializer< 0, " <<
- char_type << ", " << name << " >" << endl
+ << "const ::xsd::cxx::tree::type_serializer_initializer< " <<
+ poly_plate << ", " << char_type << ", " << name << " >" << endl
<< "_xsd_" << name << "_type_serializer_init (" << endl
<< strlit (e.name ()) << "," << endl
<< strlit (xml_ns_name (e)) << ");"
@@ -284,12 +289,17 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& e)
{
if (skip (e))
return;
+ SemanticGraph::Complex& c (
+ dynamic_cast<SemanticGraph::Complex&> (e.scope ()));
+
+ bool ordered (ordered_p (c));
+
String const& aname (eaname (e));
String ns (e.qualified_p () ? e.namespace_ ().name () : "");
String type (scope + L"::" + etype (e));
@@ -301,20 +311,23 @@ namespace CXX
// dynamically-type with xsi:type.
//
SemanticGraph::Type& t (e.type ());
- Boolean poly (polymorphic && polymorphic_p (t) && !anonymous_p (t));
+ bool poly (polymorphic && polymorphic_p (t) && !anonymous_p (t));
os << "// " << comment (e.name ()) << endl
<< "//" << endl;
- // aCC cannot handle an inline call to type_serializer_map_instance.
- //
+ if (ordered)
+ os << "case " << scope << "::" <<
+ e.context ().get<String> ("ordered-id-name") << ":"
+ << "{";
+
if (poly)
{
- os << "{"
+ os << (ordered ? "" : "{")
<< "::xsd::cxx::tree::type_serializer_map< " << char_type
<< " >& tsm (" << endl
- << "::xsd::cxx::tree::type_serializer_map_instance< 0, " <<
- char_type << " > ());"
+ << "::xsd::cxx::tree::type_serializer_map_instance< " <<
+ poly_plate << ", " << char_type << " > ());"
<< endl;
}
@@ -322,15 +335,22 @@ namespace CXX
{
// sequence
//
- os << "for (" << scope << "::" << econst_iterator (e) << endl
- << "b (i." << aname << " ().begin ()), " <<
- "n (i." << aname << " ().end ());" << endl
- << "b != n; ++b)"
- << "{";
+ if (ordered)
+ os << "const " << type << "& x (i." << aname <<
+ " ()[b->index]);"
+ << endl;
+ else
+ os << "for (" << scope << "::" << econst_iterator (e) << endl
+ << "b (i." << aname << " ().begin ()), " <<
+ "n (i." << aname << " ().end ());" << endl
+ << "b != n; ++b)"
+ << "{";
+
+ char const* x (ordered ? "x" : "*b");
if (poly)
{
- os << "if (typeid (" << type << ") == typeid (*b))"
+ os << "if (typeid (" << type << ") == typeid (" << x << "))"
<< "{"
<< xerces_ns << "::DOMElement& s (" << endl
<< "::xsd::cxx::xml::dom::create_element (" << endl
@@ -338,14 +358,14 @@ namespace CXX
<< (ns ? strlit (ns) + L",\n" : L"")
<< "e));"
<< endl
- << "s << *b;"
+ << "s << " << x << ";"
<< "}"
<< "else" << endl
<< "tsm.serialize (" << endl
<< strlit (e.name ()) << "," << endl
<< strlit (ns) << "," << endl
<< (e.global_p () ? "true" : "false") << ", " <<
- (e.qualified_p () ? "true" : "false") << ", e, *b);";
+ (e.qualified_p () ? "true" : "false") << ", e, " << x << ");";
}
else
{
@@ -360,30 +380,29 @@ namespace CXX
{
case st_other:
{
- os << "s << *b;";
+ os << "s << " << x << ";";
break;
}
case st_double:
{
- os << "s << " << as_double_type << " (*b);";
+ os << "s << " << as_double_type << " (" << x << ");";
break;
}
case st_decimal:
{
- os << "s << " << as_decimal_type << " (*b);";
+ os << "s << " << as_decimal_type << " (" << x << ");";
break;
}
}
}
-
- os << "}";
}
else if (min (e) == 0)
{
// optional
//
- os << "if (i." << aname << " ())"
- << "{";
+ if (!ordered)
+ os << "if (i." << aname << " ())"
+ << "{";
if (poly)
{
@@ -433,8 +452,6 @@ namespace CXX
}
}
}
-
- os << "}";
}
else
{
@@ -462,8 +479,10 @@ namespace CXX
}
else
{
- os << "{"
- << xerces_ns << "::DOMElement& s (" << endl
+ if (!ordered)
+ os << "{";
+
+ os << xerces_ns << "::DOMElement& s (" << endl
<< "::xsd::cxx::xml::dom::create_element (" << endl
<< strlit (e.name ()) << "," << endl
<< (ns ? strlit (ns) + L",\n" : L"")
@@ -488,13 +507,26 @@ namespace CXX
break;
}
}
-
- os << "}";
}
}
- if (poly)
+ if (ordered)
+ {
+ // See comment for bool text (false); below.
+ //
+ if (mixed_p (c) && c.context ().get<size_t> ("ordered-start") != 1)
+ os << "text = true;";
+
+ os << "continue;"
+ << "}";
+ }
+ else
+ {
os << "}";
+
+ if (poly && (max (e) != 1 || min (e) == 0))
+ os << "}"; // There is no extra block for poly one.
+ }
}
private:
@@ -508,51 +540,80 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& a)
{
+ SemanticGraph::Complex& c (
+ dynamic_cast<SemanticGraph::Complex&> (a.scope ()));
+
+ bool ordered (ordered_p (c));
+
String const& aname (eaname (a));
os << "// " << ename (a) << endl
<< "//" << endl;
+ if (ordered)
+ os << "case " << scope << "::" <<
+ a.context ().get<String> ("ordered-id-name") << ":";
+
if (max (a) != 1)
{
// sequence
//
- os << "for (" << scope << "::" << econst_iterator (a) << endl
- << "b (i." << aname << " ().begin ()), " <<
- "n (i." << aname << " ().end ());" << endl
- << "b != n; ++b)"
- << "{"
+ if (!ordered)
+ os << "for (" << scope << "::" << econst_iterator (a) << endl
+ << "b (i." << aname << " ().begin ()), " <<
+ "n (i." << aname << " ().end ());" << endl
+ << "b != n; ++b)";
+
+ os << "{"
<< "e.appendChild (" << endl
<< "e.getOwnerDocument ()->importNode (" << endl
<< "const_cast< " << xerces_ns <<
- "::DOMElement* > (&(*b)), true));"
- << "}";
+ "::DOMElement* > (&(" <<
+ (ordered ? (L"i." + aname + L" ()[b->index]") : L"*b") <<
+ ")), true));";
}
else if (min (a) == 0)
{
// optional
//
- os << "if (i." << aname << " ())"
- << "{"
+ if (!ordered)
+ os << "if (i." << aname << " ())";
+
+ os << "{"
<< "e.appendChild (" << endl
<< "e.getOwnerDocument ()->importNode (" << endl
<< "const_cast< " << xerces_ns << "::DOMElement* > (&(*i." <<
- aname << " ())), true));"
- << "}";
+ aname << " ())), true));";
}
else
{
// one
//
+ if (ordered)
+ os << "{";
+
os << "e.appendChild (" << endl
<< "e.getOwnerDocument ()->importNode (" << endl
<< "const_cast< " << xerces_ns << "::DOMElement* > (&(i." <<
aname << " ())), true));"
<< endl;
}
+
+ if (ordered)
+ {
+ // See comment for bool text (false); below.
+ //
+ if (mixed_p (c) && c.context ().get<size_t> ("ordered-start") != 1)
+ os << "text = true;";
+
+ os << "continue;";
+ }
+
+ if (ordered || max (a) != 1 || min (a) == 0)
+ os << "}";
}
private:
@@ -566,7 +627,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& a)
{
String const& aname (eaname (a));
@@ -611,8 +672,7 @@ namespace CXX
{
// Make sure we serialize required fixed attributes.
//
- if (a.optional_p () &&
- options.value<CLI::omit_default_attributes> ())
+ if (a.optional_p () && options.omit_default_attributes ())
{
os << "if (i." << aname << " () != " << scope <<
"::" << edefault_value (a) << " ())";
@@ -660,7 +720,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& a)
{
String const& aname (eaname (a));
@@ -697,9 +757,11 @@ namespace CXX
inherits_ >> base_;
}
- virtual Void
+ virtual void
traverse (Type& c)
{
+ SemanticGraph::Context& ctx (c.context ());
+
String name (ename (c));
// If renamed name is empty then we do not need to generate
@@ -729,7 +791,7 @@ namespace CXX
// Serialize anyAttribute content first so that is gets
// overriden by schema-defined attributes.
//
- if (options.value<CLI::generate_wildcard> ())
+ if (options.generate_wildcard ())
{
AnyAttribute any_attribute (*this, name);
Traversal::Names names (any_attribute);
@@ -738,24 +800,109 @@ namespace CXX
}
{
+ bool o (ordered_p (c));
+ size_t start, count;
+
+ if (o)
+ {
+ start = ctx.get<size_t> ("ordered-start");
+ count = ctx.get<size_t> ("ordered-count");
+
+ if (start != count)
+ {
+ String const& ci (ctx.get<String> ("order-const-iterator"));
+ String const& an (ctx.get<String> ("order-aname"));
+
+ // If we have mixed content and a base, then we have to
+ // skip the text content until we serialize one of "our"
+ // elements.
+ //
+ if (mixed_p (c) && start != 1)
+ os << "bool text (false);"
+ << endl;
+
+ os << "for (" << name << "::" << ci << endl
+ << "b (i." << an << " ().begin ()), n (i." << an <<
+ " ().end ());" << endl
+ << "b != n; ++b)"
+ << "{"
+ << "switch (b->id)"
+ << "{";
+ }
+ }
+
Traversal::Names names;
Any any (*this, name);
Element element (*this, name);
- Attribute attribute (*this, name);
names >> element;
- names >> attribute;
- if (options.value<CLI::generate_wildcard> ())
+ if (options.generate_wildcard ())
names >> any;
Complex::names (c, names);
+
+ if (o)
+ {
+ if (start != count)
+ {
+ if (mixed_p (c))
+ {
+ //@@ propagate mixed-ordered-id to derived
+
+ os << "// text_content" << endl
+ << "//" << endl
+ << "case " << name << "::" <<
+ ctx.get<String> ("mixed-ordered-id-name") << ":"
+ << "{";
+
+ // See the comment above.
+ //
+ if (start != 1)
+ os << "if (text)" << endl;
+
+ os << "e.appendChild (" << endl
+ << "e.getOwnerDocument ()->createTextNode (" << endl
+ << "::xsd::cxx::xml::string (" << endl
+ << "i." << ctx.get<String> ("mixed-aname") <<
+ " ()[b->index].c_str ()).c_str ()));";
+
+ // os << "e << i." << ctx.get<String> ("mixed-aname") <<
+ // " ()[b->index];";
+
+ os << "continue;"
+ << "}";
+ }
+
+ // Ignore content before our id range and stop serializing
+ // if we see anything past. This handles inheritance.
+ //
+ os << "default:"
+ << "{";
+
+ if (start != 1)
+ os << "if (b->id < " << start << "UL)" << endl
+ << "continue;";
+
+ os << "break;" // Stop (see break below).
+ << "}";
+
+ os << "}" // switch
+ << "break;" // Unknown element past our elements.
+ << "}"; // for
+ }
+ }
}
- os << "}";
+ {
+ Attribute attribute (*this, name);
+ Traversal::Names names (attribute);
+ Complex::names (c, names);
+ }
+ os << "}";
- Boolean simple (true);
+ bool simple (true);
{
IsSimpleType t (simple);
t.dispatch (c);
@@ -763,7 +910,7 @@ namespace CXX
if (simple)
{
- Boolean hb (c.inherits_p ());
+ bool hb (c.inherits_p ());
// operator<< (xercesc::DOMAttr)
//
@@ -805,7 +952,9 @@ namespace CXX
os << "}";
}
- // Register with type factory map.
+ // Register with type factory map. If this type is anonymous
+ // but substitutes, then it will be registered as part of the
+ // substitution registration.
//
if (polymorphic && polymorphic_p (c) && !anonymous_p (c))
{
@@ -814,8 +963,8 @@ namespace CXX
String const& name (ename (c));
os << "static" << endl
- << "const ::xsd::cxx::tree::type_serializer_initializer< 0, " <<
- char_type << ", " << name << " >" << endl
+ << "const ::xsd::cxx::tree::type_serializer_initializer< " <<
+ poly_plate << ", " << char_type << ", " << name << " >" << endl
<< "_xsd_" << name << "_type_serializer_init (" << endl
<< strlit (c.name ()) << "," << endl
<< strlit (xml_ns_name (c)) << ");"
@@ -842,7 +991,7 @@ namespace CXX
belongs_ >> type_name_;
}
- virtual Void
+ virtual void
traverse (Type& e)
{
if (polymorphic && e.substitutes_p ())
@@ -852,8 +1001,8 @@ namespace CXX
String const& name (ename (e));
os << "static" << endl
- << "const ::xsd::cxx::tree::element_serializer_initializer< 0, " <<
- char_type << ", ";
+ << "const ::xsd::cxx::tree::element_serializer_initializer< " <<
+ poly_plate << ", " << char_type << ", ";
belongs (e, belongs_);
@@ -881,11 +1030,11 @@ namespace CXX
ElementType (Context& c)
: GlobalElementBase (c),
Context (c),
- element_map_ (c.options.value<CLI::generate_element_map> ())
+ element_map_ (c.options.generate_element_map ())
{
}
- virtual Void
+ virtual void
traverse (Type& e)
{
if (doc_root_p (e))
@@ -921,7 +1070,7 @@ namespace CXX
}
private:
- Boolean element_map_;
+ bool element_map_;
};
struct ElementFunction: Traversal::Element,
@@ -933,7 +1082,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& e)
{
if (!doc_root_p (e))
@@ -954,7 +1103,7 @@ namespace CXX
// If this element's type is anonymous then we don't need to do
// anything.
//
- Boolean poly (polymorphic &&
+ bool poly (polymorphic &&
polymorphic_p (type) &&
!anonymous_p (type));
@@ -1137,18 +1286,11 @@ namespace CXX
if (poly)
{
- // aCC cannot handle an inline call to
- // type_serializer_map_instance.
- //
os << "}"
<< "else"
<< "{"
- << "::xsd::cxx::tree::type_serializer_map< " << char_type
- << " >& tsm (" << endl
- << "::xsd::cxx::tree::type_serializer_map_instance< 0, " <<
- char_type << " > ());"
- << endl
- << "tsm.serialize (" << endl
+ << "::xsd::cxx::tree::type_serializer_map_instance< " <<
+ poly_plate << ", " << char_type << " > ().serialize (" << endl
<< strlit (e.name ()) << "," << endl
<< strlit (e.namespace_().name ()) << "," << endl
<< "e, n, s);"
@@ -1168,37 +1310,23 @@ namespace CXX
if (poly)
{
- // aCC cannot handle an inline call to
- // type_serializer_map_instance as well as the direct
- // auto_ptr assignment.
- //
os << dom_auto_ptr << "< " << xerces_ns << "::DOMDocument > d;"
<< endl
<< "if (typeid (" << type_name (e) << ") == typeid (s))"
<< "{"
- << dom_auto_ptr << "< " << xerces_ns <<
- "::DOMDocument > r (" << endl
- << "::xsd::cxx::xml::dom::serialize< " <<
+ << "d = ::xsd::cxx::xml::dom::serialize< " <<
char_type << " > (" << endl
<< strlit (e.name ()) << "," << endl
<< strlit (ns) << "," << endl
- << "m, f));"
- << "d = r;"
+ << "m, f);"
<< "}"
<< "else"
<< "{"
- << "::xsd::cxx::tree::type_serializer_map< " << char_type
- << " >& tsm (" << endl
- << "::xsd::cxx::tree::type_serializer_map_instance< 0, " <<
- char_type << " > ());"
- << endl
- << dom_auto_ptr << "< " << xerces_ns <<
- "::DOMDocument > r (" << endl
- << "tsm.serialize (" << endl
+ << "d = ::xsd::cxx::tree::type_serializer_map_instance< " <<
+ poly_plate << ", " << char_type << " > ().serialize (" << endl
<< strlit (e.name ()) << "," << endl
<< strlit (e.namespace_().name ()) << "," << endl
- << "m, s, f));"
- << "d = r;"
+ << "m, s, f);"
<< "}";
}
else
@@ -1233,12 +1361,10 @@ namespace CXX
};
}
- Void
- generate_serialization_source (Context& ctx,
- UnsignedLong first,
- UnsignedLong last)
+ void
+ generate_serialization_source (Context& ctx, size_t first, size_t last)
{
- Boolean elemen_type (ctx.options.value<CLI::generate_element_type> ());
+ bool elemen_type (ctx.options.generate_element_type ());
if (!elemen_type)
ctx.os << "#include <ostream>" << endl
@@ -1252,8 +1378,8 @@ namespace CXX
ctx.os << "#include <xsd/cxx/tree/type-serializer-map.hxx>" << endl
<< endl;
- Boolean import_maps (ctx.options.value<CLI::import_maps> ());
- Boolean export_maps (ctx.options.value<CLI::export_maps> ());
+ bool import_maps (ctx.options.import_maps ());
+ bool export_maps (ctx.options.export_maps ());
if (import_maps || export_maps)
{
@@ -1269,19 +1395,23 @@ namespace CXX
if (export_maps)
ctx.os << "template struct __declspec (dllexport) " <<
- "type_serializer_plate< 0, " << ctx.char_type << " >;";
+ "type_serializer_plate< " << ctx.poly_plate << ", " <<
+ ctx.char_type << " >;";
if (import_maps)
ctx.os << "template struct __declspec (dllimport) " <<
- "type_serializer_plate< 0, " << ctx.char_type << " >;";
+ "type_serializer_plate< " << ctx.poly_plate << ", " <<
+ ctx.char_type << " >;";
ctx.os << "#elif defined(__GNUC__) && __GNUC__ >= 4" << endl
<< "template struct __attribute__ ((visibility(\"default\"))) " <<
- "type_serializer_plate< 0, " << ctx.char_type << " >;";
+ "type_serializer_plate< " << ctx.poly_plate << ", " <<
+ ctx.char_type << " >;";
ctx.os << "#elif defined(XSD_MAP_VISIBILITY)" << endl
<< "template struct XSD_MAP_VISIBILITY " <<
- "type_serializer_plate< 0, " << ctx.char_type << " >;";
+ "type_serializer_plate< " << ctx.poly_plate << ", " <<
+ ctx.char_type << " >;";
ctx.os << "#endif" << endl
<< "}" // tree
@@ -1294,15 +1424,15 @@ namespace CXX
ctx.os << "namespace _xsd"
<< "{"
<< "static" << endl
- << "const ::xsd::cxx::tree::type_serializer_plate< 0, " <<
- ctx.char_type << " >" << endl
+ << "const ::xsd::cxx::tree::type_serializer_plate< " <<
+ ctx.poly_plate << ", " << ctx.char_type << " >" << endl
<< "type_serializer_plate_init;"
<< "}";
}
Traversal::Schema schema;
- Traversal::Sources sources;
+ Sources sources;
Traversal::Names names_ns, names;
Namespace ns (ctx, first, last);
diff --git a/xsd/xsd/cxx/tree/serialization-source.hxx b/xsd/xsd/cxx/tree/serialization-source.hxx
index 322949a..1a74126 100644
--- a/xsd/xsd/cxx/tree/serialization-source.hxx
+++ b/xsd/xsd/cxx/tree/serialization-source.hxx
@@ -1,6 +1,5 @@
// file : xsd/cxx/tree/serialization-source.hxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#ifndef CXX_TREE_SERIALIZATION_SOURCE_HXX
@@ -12,10 +11,8 @@ namespace CXX
{
namespace Tree
{
- Void
- generate_serialization_source (Context&,
- UnsignedLong first,
- UnsignedLong last);
+ void
+ generate_serialization_source (Context&, size_t first, size_t last);
}
}
diff --git a/xsd/xsd/cxx/tree/stream-extraction-source.cxx b/xsd/xsd/cxx/tree/stream-extraction-source.cxx
index 1378bc6..ceb56c1 100644
--- a/xsd/xsd/cxx/tree/stream-extraction-source.cxx
+++ b/xsd/xsd/cxx/tree/stream-extraction-source.cxx
@@ -1,6 +1,5 @@
// file : xsd/cxx/tree/stream-extraction-source.cxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#include <cxx/tree/stream-extraction-source.hxx>
@@ -14,8 +13,6 @@ namespace CXX
{
namespace
{
- typedef Containers::Vector<NarrowString> Streams;
-
struct List: Traversal::List, Context
{
List (Context& c)
@@ -23,7 +20,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& l)
{
String name (ename (l));
@@ -45,9 +42,10 @@ namespace CXX
base += L" >";
- UnsignedLong n (0);
- Streams const& st (options.value<CLI::generate_extraction> ());
- for (Streams::ConstIterator i (st.begin ()); i != st.end (); ++i)
+ size_t n (0);
+ NarrowStrings const& st (options.generate_extraction ());
+ for (NarrowStrings::const_iterator i (st.begin ());
+ i != st.end (); ++i)
{
os << name << "::" << endl
<< name << " (" << istream_type << "< " <<
@@ -61,7 +59,9 @@ namespace CXX
// Register with type map.
//
- if (polymorphic && polymorphic_p (l) && !anonymous_p (l))
+ if (polymorphic &&
+ polymorphic_p (l) &&
+ (!anonymous_p (l) || anonymous_substitutes_p (l)))
{
// Note that we are using the original type name.
//
@@ -69,8 +69,8 @@ namespace CXX
os << "static" << endl
<< "const ::xsd::cxx::tree::stream_extraction_initializer< " <<
- "0, " << i->c_str () << ", " <<
- char_type << ", " << name << " >" << endl
+ poly_plate << ", " << i->c_str () << ", " << char_type <<
+ ", " << name << " >" << endl
<< "_xsd_" << name << "_stream_extraction_init_" <<
n++ << " (" << endl
<< strlit (l.name ()) << "," << endl
@@ -101,7 +101,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& u)
{
String name (ename (u));
@@ -114,9 +114,10 @@ namespace CXX
String const& base (xs_string_type);
- UnsignedLong n (0);
- Streams const& st (options.value<CLI::generate_extraction> ());
- for (Streams::ConstIterator i (st.begin ()); i != st.end (); ++i)
+ size_t n (0);
+ NarrowStrings const& st (options.generate_extraction ());
+ for (NarrowStrings::const_iterator i (st.begin ()); i != st.end ();
+ ++i)
{
os << name << "::" << endl
<< name << " (" << istream_type << "< " <<
@@ -129,7 +130,9 @@ namespace CXX
// Register with type map.
//
- if (polymorphic && polymorphic_p (u) && !anonymous_p (u))
+ if (polymorphic &&
+ polymorphic_p (u) &&
+ (!anonymous_p (u) || anonymous_substitutes_p (u)))
{
// Note that we are using the original type name.
//
@@ -137,8 +140,8 @@ namespace CXX
os << "static" << endl
<< "const ::xsd::cxx::tree::stream_extraction_initializer< " <<
- "0, " << i->c_str () << ", " <<
- char_type << ", " << name << " >" << endl
+ poly_plate << ", " << i->c_str () << ", " << char_type <<
+ ", " << name << " >" << endl
<< "_xsd_" << name << "_stream_extraction_init_" <<
n++ << " (" << endl
<< strlit (u.name ()) << "," << endl
@@ -158,7 +161,7 @@ namespace CXX
inherits_base_ >> base_;
}
- virtual Void
+ virtual void
traverse (Type& e)
{
String name (ename (e));
@@ -169,15 +172,30 @@ namespace CXX
if (renamed_type (e, name) && !name)
return;
- Boolean string_based (false);
+ bool string_based (false);
{
IsStringBasedType t (string_based);
t.dispatch (e);
}
- UnsignedLong n (0);
- Streams const& st (options.value<CLI::generate_extraction> ());
- for (Streams::ConstIterator i (st.begin ()); i != st.end (); ++i)
+ bool enum_based (false);
+ if (string_based)
+ {
+ SemanticGraph::Enumeration* base_enum (0);
+ IsEnumBasedType t (base_enum);
+ t.dispatch (e);
+
+ enum_based = (base_enum != 0);
+ }
+
+ String value;
+ if (string_based)
+ value = evalue (e);
+
+ size_t n (0);
+ NarrowStrings const& st (options.generate_extraction ());
+ for (NarrowStrings::const_iterator i (st.begin ()); i != st.end ();
+ ++i)
{
os << name << "::" << endl
<< name << " (" << istream_type << "< " <<
@@ -188,8 +206,18 @@ namespace CXX
inherits (e, inherits_base_);
- os << " (s, f, c)"
- << "{";
+ if (string_based && !enum_based)
+ {
+ // Use copy c-tor to pass the flags and container.
+ //
+ os << " (" << endl;
+ inherits (e, inherits_base_);
+ os << " (_xsd_" << name << "_literals_[s.read_uint ()]), f, c)";
+ }
+ else
+ os << " (s, f, c)";
+
+ os << "{";
if (string_based)
os << "_xsd_" << name << "_convert ();";
@@ -198,7 +226,9 @@ namespace CXX
// Register with type map.
//
- if (polymorphic && polymorphic_p (e) && !anonymous_p (e))
+ if (polymorphic &&
+ polymorphic_p (e) &&
+ (!anonymous_p (e) || anonymous_substitutes_p (e)))
{
// Note that we are using the original type name.
//
@@ -206,8 +236,8 @@ namespace CXX
os << "static" << endl
<< "const ::xsd::cxx::tree::stream_extraction_initializer< " <<
- "0, " << i->c_str () << ", " <<
- char_type << ", " << name << " >" << endl
+ poly_plate << ", " << i->c_str () << ", " << char_type <<
+ ", " << name << " >" << endl
<< "_xsd_" << name << "_stream_extraction_init_" <<
n++ << " (" << endl
<< strlit (e.name ()) << "," << endl
@@ -229,14 +259,14 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Member& m)
{
if (skip (m))
return;
os << "," << endl
- << " " << emember (m) << " (f, this)";
+ << " " << emember (m) << " (this)";
}
};
@@ -249,7 +279,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Any& a)
{
String const& member (emember (a));
@@ -261,7 +291,7 @@ namespace CXX
<< " " << member << " (this->" << dom_doc << " ())";
}
- virtual Void
+ virtual void
traverse (SemanticGraph::AnyAttribute& a)
{
String const& member (emember (a));
@@ -281,7 +311,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& e)
{
if (skip (e))
@@ -291,8 +321,9 @@ namespace CXX
SemanticGraph::Type& t (e.type ());
String type (etype (e));
+ String tr (etraits (e)); // traits type name
- Boolean fund (false);
+ bool fund (false);
{
IsFundamentalType traverser (fund);
traverser.dispatch (t);
@@ -304,7 +335,12 @@ namespace CXX
// from which makes it impossible to substitute or dynamically-
// type with xsi:type.
//
- Boolean poly (polymorphic && polymorphic_p (t) && !anonymous_p (t));
+ bool poly (polymorphic && polymorphic_p (t) && !anonymous_p (t));
+
+ char const* r (
+ (poly || !fund) && std >= cxx_version::cxx11
+ ? "::std::move (r)"
+ : "r");
if (max (e) != 1)
{
@@ -327,16 +363,17 @@ namespace CXX
if (poly)
{
os << "bool d;"
- << "::std::auto_ptr< " << type << " > r;"
+ << auto_ptr << "< " << type << " > r;"
<< "s >> d;"
<< endl
<< "if (!d)" << endl
<< "r.reset (new " << type << " (s, f, this));"
<< "else"
<< "{"
- << "::std::auto_ptr< ::xsd::cxx::tree::type > tmp (" << endl
- << "::xsd::cxx::tree::stream_extraction_map_instance< 0, " <<
- stream << ", " << char_type << " > ().extract (" << endl
+ << auto_ptr << "< ::xsd::cxx::tree::type > tmp (" << endl
+ << "::xsd::cxx::tree::stream_extraction_map_instance< " <<
+ poly_plate << ", " << stream << ", " << char_type <<
+ " > ().extract (" << endl
<< "s, f, this));"
<< "r.reset (dynamic_cast< " << type << "* > (tmp.get ()));"
<< "if (r.get ())" << endl
@@ -353,11 +390,11 @@ namespace CXX
}
else
{
- os << "::std::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);"
+ os << "c.push_back (" << r << ");"
<< "}" // while
<< "}" // if
<< "}";
@@ -375,16 +412,17 @@ namespace CXX
if (poly)
{
os << "bool d;"
- << "::std::auto_ptr< " << type << " > r;"
+ << auto_ptr << "< " << type << " > r;"
<< "s >> d;"
<< endl
<< "if (!d)" << endl
<< "r.reset (new " << type << " (s, f, this));"
<< "else"
<< "{"
- << "::std::auto_ptr< ::xsd::cxx::tree::type > tmp (" << endl
- << "::xsd::cxx::tree::stream_extraction_map_instance< 0, " <<
- stream << ", " << char_type << " > ().extract (" << endl
+ << auto_ptr << "< ::xsd::cxx::tree::type > tmp (" << endl
+ << "::xsd::cxx::tree::stream_extraction_map_instance< " <<
+ poly_plate << ", " << stream << ", " << char_type <<
+ " > ().extract (" << endl
<< "s, f, this));"
<< "r.reset (dynamic_cast< " << type << "* > (tmp.get ()));"
<< "if (r.get ())" << endl
@@ -401,11 +439,11 @@ namespace CXX
}
else
{
- os << "::std::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);"
+ os << "this->" << member << ".set (" << r << ");"
<< "}" // if (p)
<< "}";
}
@@ -418,16 +456,17 @@ namespace CXX
if (poly)
{
os << "bool d;"
- << "::std::auto_ptr< " << type << " > r;"
+ << auto_ptr << "< " << type << " > r;"
<< "s >> d;"
<< endl
<< "if (!d)" << endl
<< "r.reset (new " << type << " (s, f, this));"
<< "else"
<< "{"
- << "::std::auto_ptr< ::xsd::cxx::tree::type > tmp (" << endl
- << "::xsd::cxx::tree::stream_extraction_map_instance< 0, " <<
- stream << ", " << char_type << " > ().extract (" << endl
+ << auto_ptr << "< ::xsd::cxx::tree::type > tmp (" << endl
+ << "::xsd::cxx::tree::stream_extraction_map_instance< " <<
+ poly_plate << ", " << stream << ", " << char_type <<
+ " > ().extract (" << endl
<< "s, f, this));"
<< "r.reset (dynamic_cast< " << type << "* > (tmp.get ()));"
<< "if (r.get ())" << endl
@@ -444,11 +483,11 @@ namespace CXX
}
else
{
- os << "::std::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);"
+ os << "this->" << member << ".set (" << r << ");"
<< "}";
}
}
@@ -464,13 +503,14 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& a)
{
String const& member (emember (a));
String type (etype (a));
+ String tr (etraits (a)); // traits type name
- Boolean fund (false);
+ bool fund (false);
{
IsFundamentalType traverser (fund);
traverser.dispatch (a.type ());
@@ -492,9 +532,8 @@ namespace CXX
}
else
{
- os << "::std::auto_ptr< " << type << " > r (new " << type <<
- " (s, f, this));"
- << "this->" << member << ".set (r);";
+ os << "this->" << member << ".set (" << tr <<
+ "::create (s, f, this));";
}
os << "}" // if (p)
@@ -512,9 +551,8 @@ namespace CXX
}
else
{
- os << "::std::auto_ptr< " << type << " > r (new " << type <<
- " (s, f, this));"
- << "this->" << member << ".set (r);";
+ os << "this->" << member << ".set (" << tr <<
+ "::create (s, f, this));";
}
os << "}";
@@ -530,11 +568,11 @@ namespace CXX
inherits_ >> base_;
names_ctor_member_ >> ctor_member_;
- if (options.value<CLI::generate_wildcard> ())
+ if (options.generate_wildcard ())
names_ctor_member_ >> ctor_any_;
}
- virtual Void
+ virtual void
traverse (Type& c)
{
String name (ename (c));
@@ -545,9 +583,9 @@ namespace CXX
if (renamed_type (c, name) && !name)
return;
- Boolean has_members (has<Traversal::Member> (c));
+ bool has_members (has<Traversal::Member> (c));
- Boolean facets (false);
+ bool facets (false);
if (c.inherits_p ())
{
// See if we have any facets that we need to handle.
@@ -565,9 +603,10 @@ namespace CXX
}
}
- UnsignedLong n (0);
- Streams const& st (options.value<CLI::generate_extraction> ());
- for (Streams::ConstIterator i (st.begin ()); i != st.end (); ++i)
+ size_t n (0);
+ NarrowStrings const& st (options.generate_extraction ());
+ for (NarrowStrings::const_iterator i (st.begin ()); i != st.end ();
+ ++i)
{
os << name << "::" << endl
@@ -613,7 +652,8 @@ namespace CXX
<< unclash (name, "parse") << " (" <<
istream_type << "< " << i->c_str () << " >& s," << endl
<< flags_type << " f)"
- << "{";
+ << "{"
+ << "XSD_UNUSED (f);"; // Can be unused.
{
Element element (*this, *i);
Attribute attribute (*this);
@@ -631,7 +671,9 @@ namespace CXX
// Register with type map.
//
- if (polymorphic && polymorphic_p (c) && !anonymous_p (c))
+ if (polymorphic &&
+ polymorphic_p (c) &&
+ (!anonymous_p (c) || anonymous_substitutes_p (c)))
{
// Note that we are using the original type name.
//
@@ -639,8 +681,8 @@ namespace CXX
os << "static" << endl
<< "const ::xsd::cxx::tree::stream_extraction_initializer< " <<
- "0, " << i->c_str () << ", " <<
- char_type << ", " << name << " >" << endl
+ poly_plate << ", " << i->c_str () << ", " << char_type <<
+ ", " << name << " >" << endl
<< "_xsd_" << name << "_stream_extraction_init_" <<
n++ << " (" << endl
<< strlit (c.name ()) << "," << endl
@@ -661,18 +703,18 @@ namespace CXX
};
}
- Void
+ void
generate_stream_extraction_source (Context& ctx)
{
if (ctx.polymorphic)
{
- Streams const& st (ctx.options.value<CLI::generate_extraction> ());
+ NarrowStrings const& st (ctx.options.generate_extraction ());
ctx.os << "#include <xsd/cxx/tree/stream-extraction-map.hxx>" << endl
<< endl;
- Boolean import_maps (ctx.options.value<CLI::import_maps> ());
- Boolean export_maps (ctx.options.value<CLI::export_maps> ());
+ bool import_maps (ctx.options.import_maps ());
+ bool export_maps (ctx.options.export_maps ());
if (import_maps || export_maps)
{
@@ -685,7 +727,8 @@ namespace CXX
<< "namespace tree"
<< "{";
- for (Streams::ConstIterator i (st.begin ()); i != st.end (); ++i)
+ for (NarrowStrings::const_iterator i (st.begin ()); i != st.end ();
+ ++i)
{
String stream (*i);
@@ -693,22 +736,22 @@ namespace CXX
if (export_maps)
ctx.os << "template struct __declspec (dllexport) " <<
- "stream_extraction_plate< 0, " << stream << ", " <<
- ctx.char_type << " >;";
+ "stream_extraction_plate< " << ctx.poly_plate << ", " <<
+ stream << ", " << ctx.char_type << " >;";
if (import_maps)
ctx.os << "template struct __declspec (dllimport) " <<
- "stream_extraction_plate< 0, " << stream << ", " <<
- ctx.char_type << " >;";
+ "stream_extraction_plate< " << ctx.poly_plate << ", " <<
+ stream << ", " << ctx.char_type << " >;";
ctx.os << "#elif defined(__GNUC__) && __GNUC__ >= 4" << endl
<< "template struct __attribute__ ((visibility(\"default\"))) " <<
- "stream_extraction_plate< 0, " << stream << ", " <<
- ctx.char_type << " >;"
+ "stream_extraction_plate< " << ctx.poly_plate << ", " <<
+ stream << ", " << ctx.char_type << " >;"
<< "#elif defined(XSD_MAP_VISIBILITY)" << endl
<< "template struct XSD_MAP_VISIBILITY " <<
- "stream_extraction_plate< 0, " << stream << ", " <<
- ctx.char_type << " >;"
+ "stream_extraction_plate< " << ctx.poly_plate << ", " <<
+ stream << ", " << ctx.char_type << " >;"
<< "#endif" << endl;
}
@@ -723,14 +766,16 @@ namespace CXX
ctx.os << "namespace _xsd"
<< "{";
- UnsignedLong n (0);
- for (Streams::ConstIterator i (st.begin ()); i != st.end (); ++i)
+ size_t n (0);
+ for (NarrowStrings::const_iterator i (st.begin ()); i != st.end ();
+ ++i)
{
String stream (*i);
ctx.os << "static" << endl
- << "const ::xsd::cxx::tree::stream_extraction_plate< 0, " <<
- stream << ", " << ctx.char_type << " >" << endl
+ << "const ::xsd::cxx::tree::stream_extraction_plate< " <<
+ ctx.poly_plate << ", " << stream << ", " << ctx.char_type <<
+ " >" << endl
<< "stream_extraction_plate_init_" << n++ << ";";
}
@@ -739,7 +784,7 @@ namespace CXX
Traversal::Schema schema;
- Traversal::Sources sources;
+ Sources sources;
Traversal::Names names_ns, names;
Namespace ns (ctx);
diff --git a/xsd/xsd/cxx/tree/stream-extraction-source.hxx b/xsd/xsd/cxx/tree/stream-extraction-source.hxx
index 23ab17c..9104281 100644
--- a/xsd/xsd/cxx/tree/stream-extraction-source.hxx
+++ b/xsd/xsd/cxx/tree/stream-extraction-source.hxx
@@ -1,6 +1,5 @@
// file : xsd/cxx/tree/stream-extraction-source.hxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#ifndef CXX_TREE_EXTRACTION_SOURCE_HXX
@@ -12,7 +11,7 @@ namespace CXX
{
namespace Tree
{
- Void
+ void
generate_stream_extraction_source (Context&);
}
}
diff --git a/xsd/xsd/cxx/tree/stream-header.cxx b/xsd/xsd/cxx/tree/stream-header.cxx
index 02e2651..9ba9b3b 100644
--- a/xsd/xsd/cxx/tree/stream-header.cxx
+++ b/xsd/xsd/cxx/tree/stream-header.cxx
@@ -1,6 +1,5 @@
// file : xsd/cxx/tree/stream-header.cxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#include <cxx/tree/stream-header.hxx>
@@ -21,7 +20,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& l)
{
String name (ename (l));
@@ -48,7 +47,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& u)
{
String name (ename (u));
@@ -75,7 +74,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& e)
{
String name (ename (e));
@@ -86,13 +85,13 @@ namespace CXX
if (renamed_type (e, name) && !name)
return;
- Boolean string_based (false);
+ bool string_based (false);
{
IsStringBasedType t (string_based);
t.dispatch (e);
}
- Boolean enum_based (false);
+ bool enum_based (false);
if (string_based)
{
SemanticGraph::Enumeration* be (0);
@@ -129,7 +128,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& c)
{
String name (ename (c));
@@ -149,7 +148,7 @@ namespace CXX
};
}
- Void
+ void
generate_stream_header (Context& ctx)
{
String c (ctx.char_type);
@@ -159,7 +158,7 @@ namespace CXX
Traversal::Schema schema;
- Traversal::Sources sources;
+ Sources sources;
Traversal::Names names_ns, names;
Namespace ns (ctx);
diff --git a/xsd/xsd/cxx/tree/stream-header.hxx b/xsd/xsd/cxx/tree/stream-header.hxx
index 246a06e..36eea87 100644
--- a/xsd/xsd/cxx/tree/stream-header.hxx
+++ b/xsd/xsd/cxx/tree/stream-header.hxx
@@ -1,6 +1,5 @@
// file : xsd/cxx/tree/stream-header.hxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#ifndef CXX_TREE_STREAM_HEADER_HXX
@@ -12,7 +11,7 @@ namespace CXX
{
namespace Tree
{
- Void
+ void
generate_stream_header (Context&);
}
}
diff --git a/xsd/xsd/cxx/tree/stream-insertion-header.cxx b/xsd/xsd/cxx/tree/stream-insertion-header.cxx
index 1669fdd..e9ee438 100644
--- a/xsd/xsd/cxx/tree/stream-insertion-header.cxx
+++ b/xsd/xsd/cxx/tree/stream-insertion-header.cxx
@@ -1,6 +1,5 @@
// file : xsd/cxx/tree/stream-insertion-header.cxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#include <cxx/tree/stream-insertion-header.hxx>
@@ -14,8 +13,6 @@ namespace CXX
{
namespace
{
- typedef Containers::Vector<NarrowString> Streams;
-
struct List: Traversal::List, Context
{
List (Context& c)
@@ -23,7 +20,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& l)
{
String name (ename (l));
@@ -34,8 +31,9 @@ namespace CXX
if (renamed_type (l, name) && !name)
return;
- Streams const& st (options.value<CLI::generate_insertion> ());
- for (Streams::ConstIterator i (st.begin ()); i != st.end (); ++i)
+ NarrowStrings const& st (options.generate_insertion ());
+ for (NarrowStrings::const_iterator i (st.begin ()); i != st.end ();
+ ++i)
{
String stream_type (ostream_type + L"< " + String (*i) + L" >");
@@ -56,7 +54,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& u)
{
String name (ename (u));
@@ -67,8 +65,9 @@ namespace CXX
if (renamed_type (u, name) && !name)
return;
- Streams const& st (options.value<CLI::generate_insertion> ());
- for (Streams::ConstIterator i (st.begin ()); i != st.end (); ++i)
+ NarrowStrings const& st (options.generate_insertion ());
+ for (NarrowStrings::const_iterator i (st.begin ()); i != st.end ();
+ ++i)
{
String stream_type (ostream_type + L"< " + String (*i) + L" >");
@@ -89,7 +88,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& e)
{
String name (ename (e));
@@ -100,8 +99,9 @@ namespace CXX
if (renamed_type (e, name) && !name)
return;
- Streams const& st (options.value<CLI::generate_insertion> ());
- for (Streams::ConstIterator i (st.begin ()); i != st.end (); ++i)
+ NarrowStrings const& st (options.generate_insertion ());
+ for (NarrowStrings::const_iterator i (st.begin ()); i != st.end ();
+ ++i)
{
String stream_type (ostream_type + L"< " + String (*i) + L" >");
@@ -121,7 +121,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& c)
{
String name (ename (c));
@@ -132,8 +132,9 @@ namespace CXX
if (renamed_type (c, name) && !name)
return;
- Streams const& st (options.value<CLI::generate_insertion> ());
- for (Streams::ConstIterator i (st.begin ()); i != st.end (); ++i)
+ NarrowStrings const& st (options.generate_insertion ());
+ for (NarrowStrings::const_iterator i (st.begin ()); i != st.end ();
+ ++i)
{
String stream_type (ostream_type + L"< " + String (*i) + L" >");
@@ -147,14 +148,14 @@ namespace CXX
};
}
- Void
+ void
generate_stream_insertion_header (Context& ctx)
{
String c (ctx.char_type);
Traversal::Schema schema;
- Traversal::Sources sources;
+ Sources sources;
Traversal::Names names_ns, names;
Namespace ns (ctx);
diff --git a/xsd/xsd/cxx/tree/stream-insertion-header.hxx b/xsd/xsd/cxx/tree/stream-insertion-header.hxx
index ca93713..31b6328 100644
--- a/xsd/xsd/cxx/tree/stream-insertion-header.hxx
+++ b/xsd/xsd/cxx/tree/stream-insertion-header.hxx
@@ -1,6 +1,5 @@
// file : xsd/cxx/tree/stream-insertion-header.hxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#ifndef CXX_TREE_STREAM_INSERTION_HEADER_HXX
@@ -12,7 +11,7 @@ namespace CXX
{
namespace Tree
{
- Void
+ void
generate_stream_insertion_header (Context&);
}
}
diff --git a/xsd/xsd/cxx/tree/stream-insertion-source.cxx b/xsd/xsd/cxx/tree/stream-insertion-source.cxx
index 09faf71..2c82cfd 100644
--- a/xsd/xsd/cxx/tree/stream-insertion-source.cxx
+++ b/xsd/xsd/cxx/tree/stream-insertion-source.cxx
@@ -1,6 +1,5 @@
// file : xsd/cxx/tree/stream-insertion-source.cxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#include <cxx/tree/stream-insertion-source.hxx>
@@ -14,8 +13,6 @@ namespace CXX
{
namespace
{
- typedef Containers::Vector<NarrowString> Streams;
-
struct List: Traversal::List, Context
{
List (Context& c)
@@ -23,7 +20,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& l)
{
String name (ename (l));
@@ -45,9 +42,10 @@ namespace CXX
base += L" >";
- UnsignedLong n (0);
- Streams const& st (options.value<CLI::generate_insertion> ());
- for (Streams::ConstIterator i (st.begin ()); i != st.end (); ++i)
+ size_t n (0);
+ NarrowStrings const& st (options.generate_insertion ());
+ for (NarrowStrings::const_iterator i (st.begin ()); i != st.end ();
+ ++i)
{
String stream_type ("::xsd::cxx::tree::ostream< " + *i + " >");
@@ -60,7 +58,9 @@ namespace CXX
// Register with type map.
//
- if (polymorphic && polymorphic_p (l) && !anonymous_p (l))
+ if (polymorphic &&
+ polymorphic_p (l) &&
+ (!anonymous_p (l) || anonymous_substitutes_p (l)))
{
// Note that we are using the original type name.
//
@@ -68,8 +68,8 @@ namespace CXX
os << "static" << endl
<< "const ::xsd::cxx::tree::stream_insertion_initializer< " <<
- "0, " << i->c_str () << ", " <<
- char_type << ", " << name << " >" << endl
+ poly_plate << ", " << i->c_str () << ", " << char_type <<
+ ", " << name << " >" << endl
<< "_xsd_" << name << "_stream_insertion_init_" <<
n++ << " (" << endl
<< strlit (l.name ()) << "," << endl
@@ -100,7 +100,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& u)
{
String name (ename (u));
@@ -113,9 +113,10 @@ namespace CXX
String const& base (xs_string_type);
- UnsignedLong n (0);
- Streams const& st (options.value<CLI::generate_insertion> ());
- for (Streams::ConstIterator i (st.begin ()); i != st.end (); ++i)
+ size_t n (0);
+ NarrowStrings const& st (options.generate_insertion ());
+ for (NarrowStrings::const_iterator i (st.begin ()); i != st.end ();
+ ++i)
{
String stream_type ("::xsd::cxx::tree::ostream< " + *i + " >");
@@ -128,7 +129,9 @@ namespace CXX
// Register with type map.
//
- if (polymorphic && polymorphic_p (u) && !anonymous_p (u))
+ if (polymorphic &&
+ polymorphic_p (u) &&
+ (!anonymous_p (u) || anonymous_substitutes_p (u)))
{
// Note that we are using the original type name.
//
@@ -136,8 +139,8 @@ namespace CXX
os << "static" << endl
<< "const ::xsd::cxx::tree::stream_insertion_initializer< " <<
- "0, " << i->c_str () << ", " <<
- char_type << ", " << name << " >" << endl
+ poly_plate << ", " << i->c_str () << ", " << char_type <<
+ ", " << name << " >" << endl
<< "_xsd_" << name << "_stream_insertion_init_" <<
n++ << " (" << endl
<< strlit (u.name ()) << "," << endl
@@ -157,7 +160,7 @@ namespace CXX
inherits_base_ >> base_;
}
- virtual Void
+ virtual void
traverse (Type& e)
{
String name (ename (e));
@@ -168,26 +171,57 @@ namespace CXX
if (renamed_type (e, name) && !name)
return;
- UnsignedLong n (0);
- Streams const& st (options.value<CLI::generate_insertion> ());
- for (Streams::ConstIterator i (st.begin ()); i != st.end (); ++i)
+ bool string_based (false);
+ {
+ IsStringBasedType t (string_based);
+ t.dispatch (e);
+ }
+
+ bool enum_based (false);
+ if (string_based)
+ {
+ SemanticGraph::Enumeration* base_enum (0);
+ IsEnumBasedType t (base_enum);
+ t.dispatch (e);
+
+ enum_based = (base_enum != 0);
+ }
+
+ String value;
+ if (string_based)
+ value = evalue (e);
+
+ size_t n (0);
+ NarrowStrings const& st (options.generate_insertion ());
+ for (NarrowStrings::const_iterator i (st.begin ()); i != st.end ();
+ ++i)
{
String stream_type ("::xsd::cxx::tree::ostream< " + *i + " >");
os << stream_type << "&" << endl
<< "operator<< (" << stream_type << "& s," << endl
<< "const " << name << "& x)"
- << "{"
- << "return s << static_cast< const ";
+ << "{";
- inherits (e, inherits_base_);
+ if (!string_based || enum_based)
+ {
+ os << "return s << static_cast< const ";
+ inherits (e, inherits_base_);
+ os << "& > (x);";
+ }
+ else
+ {
+ os << name << "::" << value << " v (x);"
+ << "return s << static_cast< unsigned int > (v);";
+ }
- os << "& > (x);"
- << "}";
+ os << "}";
// Register with type map.
//
- if (polymorphic && polymorphic_p (e) && !anonymous_p (e))
+ if (polymorphic &&
+ polymorphic_p (e) &&
+ (!anonymous_p (e) || anonymous_substitutes_p (e)))
{
// Note that we are using the original type name.
//
@@ -195,8 +229,8 @@ namespace CXX
os << "static" << endl
<< "const ::xsd::cxx::tree::stream_insertion_initializer< " <<
- "0, " << i->c_str () << ", " <<
- char_type << ", " << name << " >" << endl
+ poly_plate << ", " << i->c_str () << ", " << char_type <<
+ ", " << name << " >" << endl
<< "_xsd_" << name << "_stream_insertion_init_" <<
n++ << " (" << endl
<< strlit (e.name ()) << "," << endl
@@ -218,7 +252,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& e)
{
if (skip (e)) return;
@@ -233,7 +267,7 @@ namespace CXX
// from which makes it impossible to substitute or dynamically-
// type with xsi:type.
//
- Boolean poly (polymorphic && polymorphic_p (t) && !anonymous_p (t));
+ bool poly (polymorphic && polymorphic_p (t) && !anonymous_p (t));
if (max (e) != 1)
{
@@ -257,8 +291,9 @@ namespace CXX
<< "if (!d)" << endl
<< "s << *i;"
<< "else" << endl
- << "::xsd::cxx::tree::stream_insertion_map_instance< 0, " <<
- stream << ", " << char_type << " > ().insert (s, *i);";
+ << "::xsd::cxx::tree::stream_insertion_map_instance< " <<
+ poly_plate << ", " << stream << ", " << char_type <<
+ " > ().insert (s, *i);";
}
else
os << "s << *i;";
@@ -284,8 +319,9 @@ namespace CXX
<< "if (!d)" << endl
<< "s << i;"
<< "else" << endl
- << "::xsd::cxx::tree::stream_insertion_map_instance< 0, " <<
- stream << ", " << char_type << " > ().insert (s, i);"
+ << "::xsd::cxx::tree::stream_insertion_map_instance< " <<
+ poly_plate << ", " << stream << ", " << char_type <<
+ " > ().insert (s, i);"
<< "}";
}
else
@@ -307,8 +343,9 @@ namespace CXX
<< "if (!d)" << endl
<< "s << i;"
<< "else" << endl
- << "::xsd::cxx::tree::stream_insertion_map_instance< 0, " <<
- stream << ", " << char_type << " > ().insert (s, i);"
+ << "::xsd::cxx::tree::stream_insertion_map_instance< " <<
+ poly_plate << ", " << stream << ", " << char_type <<
+ " > ().insert (s, i);"
<< "}";
}
else
@@ -328,7 +365,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& a)
{
String const& aname (eaname (a));
@@ -358,7 +395,7 @@ namespace CXX
inherits_ >> base_;
}
- virtual Void
+ virtual void
traverse (Type& c)
{
String name (ename (c));
@@ -369,11 +406,12 @@ namespace CXX
if (renamed_type (c, name) && !name)
return;
- Boolean has_body (has<Traversal::Member> (c) || c.inherits_p ());
+ bool has_body (has<Traversal::Member> (c) || c.inherits_p ());
- UnsignedLong n (0);
- Streams const& st (options.value<CLI::generate_insertion> ());
- for (Streams::ConstIterator i (st.begin ()); i != st.end (); ++i)
+ size_t n (0);
+ NarrowStrings const& st (options.generate_insertion ());
+ for (NarrowStrings::const_iterator i (st.begin ()); i != st.end ();
+ ++i)
{
String stream_type ("::xsd::cxx::tree::ostream< " + *i + " >");
@@ -408,7 +446,9 @@ namespace CXX
// Register with type map.
//
- if (polymorphic && polymorphic_p (c) && !anonymous_p (c))
+ if (polymorphic &&
+ polymorphic_p (c) &&
+ (!anonymous_p (c) || anonymous_substitutes_p (c)))
{
// Note that we are using the original type name.
//
@@ -416,8 +456,8 @@ namespace CXX
os << "static" << endl
<< "const ::xsd::cxx::tree::stream_insertion_initializer< " <<
- "0, " << i->c_str () << ", " <<
- char_type << ", " << name << " >" << endl
+ poly_plate << ", " << i->c_str () << ", " << char_type <<
+ ", " << name << " >" << endl
<< "_xsd_" << name << "_stream_insertion_init_" <<
n++ << " (" << endl
<< strlit (c.name ()) << "," << endl
@@ -433,18 +473,18 @@ namespace CXX
};
}
- Void
+ void
generate_stream_insertion_source (Context& ctx)
{
if (ctx.polymorphic)
{
- Streams const& st (ctx.options.value<CLI::generate_insertion> ());
+ NarrowStrings const& st (ctx.options.generate_insertion ());
ctx.os << "#include <xsd/cxx/tree/stream-insertion-map.hxx>" << endl
<< endl;
- Boolean import_maps (ctx.options.value<CLI::import_maps> ());
- Boolean export_maps (ctx.options.value<CLI::export_maps> ());
+ bool import_maps (ctx.options.import_maps ());
+ bool export_maps (ctx.options.export_maps ());
if (import_maps || export_maps)
{
@@ -457,7 +497,8 @@ namespace CXX
<< "namespace tree"
<< "{";
- for (Streams::ConstIterator i (st.begin ()); i != st.end (); ++i)
+ for (NarrowStrings::const_iterator i (st.begin ()); i != st.end ();
+ ++i)
{
String stream (*i);
@@ -465,22 +506,22 @@ namespace CXX
if (export_maps)
ctx.os << "template struct __declspec (dllexport) " <<
- "stream_insertion_plate< 0, " << stream << ", " <<
- ctx.char_type << " >;";
+ "stream_insertion_plate< " << ctx.poly_plate << ", " <<
+ stream << ", " << ctx.char_type << " >;";
if (import_maps)
ctx.os << "template struct __declspec (dllimport) " <<
- "stream_insertion_plate< 0, " << stream << ", " <<
- ctx.char_type << " >;";
+ "stream_insertion_plate< " << ctx.poly_plate << ", " <<
+ stream << ", " << ctx.char_type << " >;";
ctx.os << "#elif defined(__GNUC__) && __GNUC__ >= 4" << endl
<< "template struct __attribute__ ((visibility(\"default\"))) " <<
- "stream_insertion_plate< 0, " << stream << ", " <<
- ctx.char_type << " >;"
+ "stream_insertion_plate< " << ctx.poly_plate << ", " <<
+ stream << ", " << ctx.char_type << " >;"
<< "#elif defined(XSD_MAP_VISIBILITY)" << endl
<< "template struct XSD_MAP_VISIBILITY " <<
- "stream_insertion_plate< 0, " << stream << ", " <<
- ctx.char_type << " >;"
+ "stream_insertion_plate< " << ctx.poly_plate << ", " <<
+ stream << ", " << ctx.char_type << " >;"
<< "#endif" << endl;
}
@@ -494,14 +535,16 @@ namespace CXX
ctx.os << "namespace _xsd"
<< "{";
- UnsignedLong n (0);
- for (Streams::ConstIterator i (st.begin ()); i != st.end (); ++i)
+ size_t n (0);
+ for (NarrowStrings::const_iterator i (st.begin ()); i != st.end ();
+ ++i)
{
String stream (*i);
ctx.os << "static" << endl
- << "const ::xsd::cxx::tree::stream_insertion_plate< 0, " <<
- stream << ", " << ctx.char_type << " >" << endl
+ << "const ::xsd::cxx::tree::stream_insertion_plate< " <<
+ ctx.poly_plate << ", " << stream << ", " << ctx.char_type <<
+ " >" << endl
<< "stream_insertion_plate_init_" << n++ << ";";
}
@@ -510,7 +553,7 @@ namespace CXX
Traversal::Schema schema;
- Traversal::Sources sources;
+ Sources sources;
Traversal::Names names_ns, names;
Namespace ns (ctx);
diff --git a/xsd/xsd/cxx/tree/stream-insertion-source.hxx b/xsd/xsd/cxx/tree/stream-insertion-source.hxx
index b270912..d2d5534 100644
--- a/xsd/xsd/cxx/tree/stream-insertion-source.hxx
+++ b/xsd/xsd/cxx/tree/stream-insertion-source.hxx
@@ -1,6 +1,5 @@
// file : xsd/cxx/tree/stream-insertion-source.hxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#ifndef CXX_TREE_INSERTION_SOURCE_HXX
@@ -12,7 +11,7 @@ namespace CXX
{
namespace Tree
{
- Void
+ void
generate_stream_insertion_source (Context&);
}
}
diff --git a/xsd/xsd/cxx/tree/stream-source.cxx b/xsd/xsd/cxx/tree/stream-source.cxx
index e8a7fc4..935ad40 100644
--- a/xsd/xsd/cxx/tree/stream-source.cxx
+++ b/xsd/xsd/cxx/tree/stream-source.cxx
@@ -1,6 +1,5 @@
// file : xsd/cxx/tree/stream-source.cxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#include <cxx/tree/stream-source.hxx>
@@ -21,7 +20,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& l)
{
String name (ename (l));
@@ -52,15 +51,17 @@ namespace CXX
// Register with ostream map.
//
- if (polymorphic && polymorphic_p (l) && !anonymous_p (l))
+ if (polymorphic &&
+ polymorphic_p (l) &&
+ (!anonymous_p (l) || anonymous_substitutes_p (l)))
{
// Note that we are using the original type name.
//
String const& name (ename (l));
os << "static" << endl
- << "const ::xsd::cxx::tree::std_ostream_initializer< 0, " <<
- char_type << ", " << name << " >" << endl
+ << "const ::xsd::cxx::tree::std_ostream_initializer< " <<
+ poly_plate << ", " << char_type << ", " << name << " >" << endl
<< "_xsd_" << name << "_std_ostream_init;"
<< endl;
}
@@ -87,7 +88,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& u)
{
String name (ename (u));
@@ -107,15 +108,17 @@ namespace CXX
// Register with ostream map.
//
- if (polymorphic && polymorphic_p (u) && !anonymous_p (u))
+ if (polymorphic &&
+ polymorphic_p (u) &&
+ (!anonymous_p (u) || anonymous_substitutes_p (u)))
{
// Note that we are using the original type name.
//
String const& name (ename (u));
os << "static" << endl
- << "const ::xsd::cxx::tree::std_ostream_initializer< 0, " <<
- char_type << ", " << name << " >" << endl
+ << "const ::xsd::cxx::tree::std_ostream_initializer< " <<
+ poly_plate << ", " << char_type << ", " << name << " >" << endl
<< "_xsd_" << name << "_std_ostream_init;"
<< endl;
}
@@ -131,7 +134,7 @@ namespace CXX
inherits_base_ >> base_;
}
- virtual Void
+ virtual void
traverse (Type& e)
{
String name (ename (e));
@@ -142,13 +145,13 @@ namespace CXX
if (renamed_type (e, name) && !name)
return;
- Boolean string_based (false);
+ bool string_based (false);
{
IsStringBasedType t (string_based);
t.dispatch (e);
}
- Boolean enum_based (false);
+ bool enum_based (false);
if (string_based)
{
SemanticGraph::Enumeration* be (0);
@@ -185,15 +188,17 @@ namespace CXX
// Register with ostream map.
//
- if (polymorphic && polymorphic_p (e) && !anonymous_p (e))
+ if (polymorphic &&
+ polymorphic_p (e) &&
+ (!anonymous_p (e) || anonymous_substitutes_p (e)))
{
// Note that we are using the original type name.
//
String const& name (ename (e));
os << "static" << endl
- << "const ::xsd::cxx::tree::std_ostream_initializer< 0, " <<
- char_type << ", " << name << " >" << endl
+ << "const ::xsd::cxx::tree::std_ostream_initializer< " <<
+ poly_plate << ", " << char_type << ", " << name << " >" << endl
<< "_xsd_" << name << "_std_ostream_init;"
<< endl;
}
@@ -211,7 +216,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& e)
{
if (skip (e))
@@ -226,17 +231,15 @@ namespace CXX
// dynamically-type with xsi:type.
//
SemanticGraph::Type& t (e.type ());
- Boolean poly (polymorphic && polymorphic_p (t) && !anonymous_p (t));
+ bool poly (polymorphic && polymorphic_p (t) && !anonymous_p (t));
- // aCC cannot handle an inline call to std_ostream_map_instance.
- //
if (poly)
{
os << "{"
<< "::xsd::cxx::tree::std_ostream_map< " << char_type
<< " >& om (" << endl
- << "::xsd::cxx::tree::std_ostream_map_instance< 0, " <<
- char_type << " > ());"
+ << "::xsd::cxx::tree::std_ostream_map_instance< " <<
+ poly_plate << ", " << char_type << " > ());"
<< endl;
}
@@ -304,7 +307,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& a)
{
String const& aname (eaname (a));
@@ -334,7 +337,7 @@ namespace CXX
inherits_ >> base_;
}
- virtual Void
+ virtual void
traverse (Type& c)
{
String name (ename (c));
@@ -347,7 +350,7 @@ namespace CXX
//
//
- Boolean has_body (has<Traversal::Member> (c) || c.inherits_p ());
+ bool has_body (has<Traversal::Member> (c) || c.inherits_p ());
os << std_ostream_type << "&" << endl
<< "operator<< (" << std_ostream_type << "& o, " <<
@@ -380,15 +383,17 @@ namespace CXX
// Register with ostream map.
//
- if (polymorphic && polymorphic_p (c) && !anonymous_p (c))
+ if (polymorphic &&
+ polymorphic_p (c) &&
+ (!anonymous_p (c) || anonymous_substitutes_p (c)))
{
// Note that we are using the original type name.
//
String const& name (ename (c));
os << "static" << endl
- << "const ::xsd::cxx::tree::std_ostream_initializer< 0, " <<
- char_type << ", " << name << " >" << endl
+ << "const ::xsd::cxx::tree::std_ostream_initializer< " <<
+ poly_plate << ", " << char_type << ", " << name << " >" << endl
<< "_xsd_" << name << "_std_ostream_init;"
<< endl;
}
@@ -400,10 +405,8 @@ namespace CXX
};
}
- Void
- generate_stream_source (Context& ctx,
- UnsignedLong first,
- UnsignedLong last)
+ void
+ generate_stream_source (Context& ctx, size_t first, size_t last)
{
String c (ctx.char_type);
@@ -415,8 +418,8 @@ namespace CXX
ctx.os << "#include <xsd/cxx/tree/std-ostream-map.hxx>" << endl
<< endl;
- Boolean import_maps (ctx.options.value<CLI::import_maps> ());
- Boolean export_maps (ctx.options.value<CLI::export_maps> ());
+ bool import_maps (ctx.options.import_maps ());
+ bool export_maps (ctx.options.export_maps ());
if (import_maps || export_maps)
{
@@ -432,19 +435,23 @@ namespace CXX
if (export_maps)
ctx.os << "template struct __declspec (dllexport) " <<
- "std_ostream_plate< 0, " << ctx.char_type << " >;";
+ "std_ostream_plate< " << ctx.poly_plate << ", " <<
+ ctx.char_type << " >;";
if (import_maps)
ctx.os << "template struct __declspec (dllimport) " <<
- "std_ostream_plate< 0, " << ctx.char_type << " >;";
+ "std_ostream_plate< " << ctx.poly_plate << ", " <<
+ ctx.char_type << " >;";
ctx.os << "#elif defined(__GNUC__) && __GNUC__ >= 4" << endl
<< "template struct __attribute__ ((visibility(\"default\"))) " <<
- "std_ostream_plate< 0, " << ctx.char_type << " >;";
+ "std_ostream_plate< " << ctx.poly_plate << ", " << ctx.char_type <<
+ " >;";
ctx.os << "#elif defined(XSD_MAP_VISIBILITY)" << endl
<< "template struct XSD_MAP_VISIBILITY " <<
- "std_ostream_plate< 0, " << ctx.char_type << " >;";
+ "std_ostream_plate< " << ctx.poly_plate << ", " << ctx.char_type <<
+ " >;";
ctx.os << "#endif" << endl
<< "}" // tree
@@ -457,15 +464,15 @@ namespace CXX
ctx.os << "namespace _xsd"
<< "{"
<< "static" << endl
- << "const ::xsd::cxx::tree::std_ostream_plate< 0, " <<
- ctx.char_type << " >" << endl
+ << "const ::xsd::cxx::tree::std_ostream_plate< " <<
+ ctx.poly_plate << ", " << ctx.char_type << " >" << endl
<< "std_ostream_plate_init;"
<< "}";
}
Traversal::Schema schema;
- Traversal::Sources sources;
+ Sources sources;
Traversal::Names names_ns, names;
Namespace ns (ctx, first, last);
diff --git a/xsd/xsd/cxx/tree/stream-source.hxx b/xsd/xsd/cxx/tree/stream-source.hxx
index 13e8f37..f13a23e 100644
--- a/xsd/xsd/cxx/tree/stream-source.hxx
+++ b/xsd/xsd/cxx/tree/stream-source.hxx
@@ -1,6 +1,5 @@
// file : xsd/cxx/tree/stream-source.hxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#ifndef CXX_TREE_STREAM_SOURCE_HXX
@@ -12,10 +11,8 @@ namespace CXX
{
namespace Tree
{
- Void
- generate_stream_source (Context&,
- UnsignedLong first,
- UnsignedLong last);
+ void
+ generate_stream_source (Context&, size_t first, size_t last);
}
}
diff --git a/xsd/xsd/cxx/tree/tree-forward.cxx b/xsd/xsd/cxx/tree/tree-forward.cxx
index 214cc75..5afae3c 100644
--- a/xsd/xsd/cxx/tree/tree-forward.cxx
+++ b/xsd/xsd/cxx/tree/tree-forward.cxx
@@ -1,6 +1,5 @@
// file : xsd/cxx/tree/tree-forward.cxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#include <cxx/tree/tree-forward.hxx>
@@ -22,7 +21,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& l)
{
String const& name (ename (l));
@@ -52,7 +51,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& u)
{
String const& name (ename (u));
@@ -82,7 +81,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& e)
{
String const& name (ename (e));
@@ -112,7 +111,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& c)
{
String const& name (ename (c));
@@ -136,16 +135,16 @@ namespace CXX
};
}
- Void
+ void
generate_forward (Context& ctx)
{
- NarrowString xml_schema (ctx.options.value<CLI::extern_xml_schema> ());
+ NarrowString xml_schema (ctx.options.extern_xml_schema ());
// Inlcude or Emit fundamental types.
//
if (xml_schema)
{
- String name (ctx.hxx_expr->merge (xml_schema));
+ String name (ctx.hxx_expr->replace (xml_schema));
ctx.os << "#include " << ctx.process_include_path (name) << endl
<< endl;
@@ -164,21 +163,21 @@ namespace CXX
<< "#include <xsd/cxx/tree/types.hxx>" << endl
<< endl;
- if (!ctx.options.value<CLI::suppress_parsing> () ||
- ctx.options.value<CLI::generate_serialization> ())
+ if (!ctx.options.suppress_parsing () ||
+ ctx.options.generate_serialization ())
{
ctx.os << "#include <xsd/cxx/xml/error-handler.hxx>" << endl
<< endl;
}
- if (!ctx.options.value<CLI::suppress_parsing> () ||
- ctx.options.value<CLI::generate_serialization> ())
+ if (!ctx.options.suppress_parsing () ||
+ ctx.options.generate_serialization ())
{
ctx.os << "#include <xsd/cxx/xml/dom/auto-ptr.hxx>" << endl
<< endl;
}
- Boolean element_map (ctx.options.value<CLI::generate_element_map> ());
+ bool element_map (ctx.options.generate_element_map ());
if (element_map)
ctx.os << "#include <xsd/cxx/tree/element-map.hxx>" << endl
@@ -188,7 +187,7 @@ namespace CXX
// later in the individual generators for each feature because
// those headers provide implementation for the fundamental types.
//
- if (!ctx.options.value<CLI::suppress_parsing> ())
+ if (!ctx.options.suppress_parsing ())
{
ctx.os << "#include <xsd/cxx/tree/parsing.hxx>" << endl;
@@ -210,7 +209,7 @@ namespace CXX
ctx.os << endl;
}
- if (ctx.options.value<CLI::generate_serialization> ())
+ if (ctx.options.generate_serialization ())
{
ctx.os << "#include <xsd/cxx/xml/dom/serialization-header.hxx>" << endl
<< "#include <xsd/cxx/tree/serialization.hxx>" << endl;
@@ -233,18 +232,17 @@ namespace CXX
ctx.os << endl;
}
- if (ctx.options.value<CLI::generate_ostream> ())
+ if (ctx.options.generate_ostream ())
{
ctx.os << "#include <xsd/cxx/tree/std-ostream-operators.hxx>" << endl
<< endl;
}
- typedef Containers::Vector<NarrowString> Streams;
-
- Streams const& ist (ctx.options.value<CLI::generate_insertion> ());
+ NarrowStrings const& ist (ctx.options.generate_insertion ());
if (!ist.empty ())
{
- for (Streams::ConstIterator i (ist.begin ()); i != ist.end (); ++i)
+ for (NarrowStrings::const_iterator i (ist.begin ()); i != ist.end ();
+ ++i)
{
if (*i == "ACE_OutputCDR")
ctx.os << "#include <xsd/cxx/tree/ace-cdr-stream-insertion.hxx>"
@@ -258,10 +256,11 @@ namespace CXX
<< endl;
}
- Streams const& est (ctx.options.value<CLI::generate_extraction> ());
+ NarrowStrings const& est (ctx.options.generate_extraction ());
if (!est.empty ())
{
- for (Streams::ConstIterator i (est.begin ()); i != est.end (); ++i)
+ for (NarrowStrings::const_iterator i (est.begin ()); i != est.end ();
+ ++i)
{
if (*i == "ACE_InputCDR")
ctx.os << "#include <xsd/cxx/tree/ace-cdr-stream-extraction.hxx>"
@@ -288,7 +287,7 @@ namespace CXX
// First emit header includes.
//
- if (ctx.options.value<CLI::generate_forward> ())
+ if (ctx.options.generate_forward ())
{
Traversal::Schema schema;
Includes includes (ctx, Includes::forward);
@@ -302,7 +301,7 @@ namespace CXX
<< "//" << endl;
Traversal::Schema schema;
- Traversal::Sources sources;
+ Sources sources;
Traversal::Names names_ns, names;
Namespace ns (ctx);
diff --git a/xsd/xsd/cxx/tree/tree-forward.hxx b/xsd/xsd/cxx/tree/tree-forward.hxx
index efe0e02..5b08a10 100644
--- a/xsd/xsd/cxx/tree/tree-forward.hxx
+++ b/xsd/xsd/cxx/tree/tree-forward.hxx
@@ -1,6 +1,5 @@
// file : xsd/cxx/tree/tree-forward.hxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#ifndef CXX_TREE_TREE_FORWARD_HXX
@@ -12,7 +11,7 @@ namespace CXX
{
namespace Tree
{
- Void
+ void
generate_forward (Context&);
}
}
diff --git a/xsd/xsd/cxx/tree/tree-header.cxx b/xsd/xsd/cxx/tree/tree-header.cxx
index 9b5acc6..f0c3560 100644
--- a/xsd/xsd/cxx/tree/tree-header.cxx
+++ b/xsd/xsd/cxx/tree/tree-header.cxx
@@ -1,6 +1,5 @@
// file : xsd/cxx/tree/tree-header.cxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#include <xsd-frontend/semantic-graph.hxx>
@@ -16,8 +15,6 @@ namespace CXX
{
namespace
{
- typedef Containers::Vector<NarrowString> Streams;
-
// List mapping.
//
struct List: Traversal::List, Context
@@ -27,7 +24,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& l)
{
String name (ename (l));
@@ -142,8 +139,9 @@ namespace CXX
// c-tor (istream&)
//
- Streams const& st (options.value<CLI::generate_extraction> ());
- for (Streams::ConstIterator i (st.begin ()); i != st.end (); ++i)
+ NarrowStrings const& st (options.generate_extraction ());
+ for (NarrowStrings::const_iterator i (st.begin ()); i != st.end ();
+ ++i)
{
if (doxygen)
{
@@ -167,7 +165,7 @@ namespace CXX
<< endl;
}
- if (!options.value<CLI::suppress_parsing> ())
+ if (!options.suppress_parsing ())
{
// c-tor (xercesc::DOMElement)
//
@@ -293,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:
@@ -318,7 +332,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& u)
{
String name (ename (u));
@@ -353,7 +367,7 @@ namespace CXX
<< "public:" << endl
<< endl;
- if (options.value<CLI::generate_default_ctor> ())
+ if (options.generate_default_ctor ())
{
// c-tor ()
//
@@ -400,8 +414,9 @@ namespace CXX
// c-tor (istream&)
//
- Streams const& st (options.value<CLI::generate_extraction> ());
- for (Streams::ConstIterator i (st.begin ()); i != st.end (); ++i)
+ NarrowStrings const& st (options.generate_extraction ());
+ for (NarrowStrings::const_iterator i (st.begin ()); i != st.end ();
+ ++i)
{
if (doxygen)
{
@@ -425,7 +440,7 @@ namespace CXX
<< endl;
}
- if (!options.value<CLI::suppress_parsing> ())
+ if (!options.suppress_parsing ())
{
// c-tor (xercesc::DOMElement)
//
@@ -551,7 +566,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& e)
{
if (doxygen && e.annotated_p ())
@@ -579,7 +594,7 @@ namespace CXX
names_ >> enumerator_;
}
- virtual Void
+ virtual void
traverse (Type& e)
{
String name (ename (e));
@@ -590,13 +605,13 @@ namespace CXX
if (renamed_type (e, name) && !name)
return;
- Boolean string_based (false);
+ bool string_based (false);
{
IsStringBasedType t (string_based);
t.dispatch (e);
}
- Boolean enum_based (false);
+ bool enum_based (false);
SemanticGraph::Enumeration* base_enum (0);
if (string_based)
@@ -614,7 +629,7 @@ namespace CXX
// Get to the ultimate base and see if is a fundamental type.
//
- Boolean fund_based (false);
+ bool fund_based (false);
SemanticGraph::Type& ult_base (ultimate_base (e));
{
IsFundamentalType t (fund_based);
@@ -623,7 +638,7 @@ namespace CXX
// Count enumerators.
//
- UnsignedLong enum_count (0);
+ size_t enum_count (0);
for (Type::NamesIterator i (e.names_begin ()), end (e.names_end ());
i != end; ++i)
@@ -688,7 +703,7 @@ namespace CXX
// default c-tor
//
- if (options.value<CLI::generate_default_ctor> ())
+ if (options.generate_default_ctor ())
{
if (doxygen)
{
@@ -808,8 +823,9 @@ namespace CXX
// c-tor (istream&)
//
- Streams const& st (options.value<CLI::generate_extraction> ());
- for (Streams::ConstIterator i (st.begin ()); i != st.end (); ++i)
+ NarrowStrings const& st (options.generate_extraction ());
+ for (NarrowStrings::const_iterator i (st.begin ()); i != st.end ();
+ ++i)
{
if (doxygen)
{
@@ -833,7 +849,7 @@ namespace CXX
<< endl;
}
- if (!options.value<CLI::suppress_parsing> ())
+ if (!options.suppress_parsing ())
{
// c-tor (xercesc::DOMElement)
//
@@ -1031,7 +1047,7 @@ namespace CXX
os << "};";
}
- virtual Void
+ virtual void
comma (Type&)
{
os << "," << endl;
@@ -1058,7 +1074,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& m)
{
if (skip (m))
@@ -1069,14 +1085,14 @@ namespace CXX
String kind (m.is_a<SemanticGraph::Element> ()
? "element" : "attribute");
- Boolean fund (false);
+ bool fund (false);
{
IsFundamentalType t (fund);
t.dispatch (m.type ());
}
- Boolean def_attr (m.default_p () &&
- m.is_a<SemanticGraph::Attribute> ());
+ bool def_attr (m.default_p () &&
+ m.is_a<SemanticGraph::Attribute> ());
if (max (m) != 1)
{
@@ -1249,7 +1265,7 @@ namespace CXX
}
os << "void" << endl
- << mname << " (::std::auto_ptr< " << type << " > p);"
+ << mname << " (" << auto_ptr << "< " << type << " > p);"
<< endl;
}
}
@@ -1338,7 +1354,7 @@ namespace CXX
}
os << "void" << endl
- << mname << " (::std::auto_ptr< " << type << " > p);"
+ << mname << " (" << auto_ptr << "< " << type << " > p);"
<< endl;
}
@@ -1362,7 +1378,7 @@ namespace CXX
<< " */" << endl;
}
- os << "::std::auto_ptr< " << type << " >" << endl
+ os << auto_ptr << "< " << type << " >" << endl
<< edname (m) << " ();"
<< endl;
}
@@ -1373,7 +1389,7 @@ namespace CXX
//
if (m.default_p ())
{
- Boolean simple (true);
+ bool simple (true);
if (m.is_a<SemanticGraph::Element> ())
{
@@ -1383,7 +1399,7 @@ namespace CXX
if (simple)
{
- Boolean lit (false);
+ bool lit (false);
{
IsLiteralValue test (lit);
test.dispatch (m.type ());
@@ -1425,7 +1441,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Any& a)
{
String const& aname (eaname (a));
@@ -1698,7 +1714,7 @@ namespace CXX
}
}
- virtual Void
+ virtual void
traverse (SemanticGraph::AnyAttribute& a)
{
String const& aname (eaname (a));
@@ -1778,16 +1794,19 @@ namespace CXX
belongs_ >> type_name_;
}
- virtual Void
+ virtual void
traverse (Type& m)
{
if (skip (m))
return;
+ SemanticGraph::Complex& c (
+ dynamic_cast<SemanticGraph::Complex&> (m.scope ()));
+
String const& type (etype (m));
- Boolean el (m.is_a<SemanticGraph::Element> ());
+ bool el (m.is_a<SemanticGraph::Element> ());
- Boolean def_attr (m.default_p () && !el);
+ bool def_attr (m.default_p () && !el);
if (doxygen)
{
@@ -1826,7 +1845,7 @@ namespace CXX
else
{
os << "// " << comment (m.name ()) << endl
- << "// " << endl;
+ << "//" << endl;
}
// Typedefs.
@@ -1849,7 +1868,7 @@ namespace CXX
if (max (m) != 1)
{
String const& container (econtainer (m));
- Boolean isense (options.value<CLI::generate_intellisense> ());
+ bool isense (options.generate_intellisense ());
// sequence
//
@@ -1872,7 +1891,7 @@ namespace CXX
<< " */" << endl;
}
- // IntelliSense does not not like aliases and fully-qualified
+ // IntelliSense does not like aliases and fully-qualified
// names here.
//
if (!isense)
@@ -1941,6 +1960,24 @@ namespace CXX
os << " > " << etraits (m) << ";"
<< endl;
+
+ // Element id.
+ //
+ if (el && ordered_p (c))
+ {
+ if (doxygen)
+ os << "/**" << endl
+ << " * @brief Element id used for capturing content " <<
+ "order." << endl
+ << " */" << endl;
+
+ SemanticGraph::Context& ctx (m.context ());
+
+ os << "static const ::std::size_t " <<
+ ctx.get<String> ("ordered-id-name") << " = " <<
+ ctx.get<size_t> ("ordered-id") << "UL;" << endl;
+ }
+
member_function_.traverse (m);
if (doxygen)
@@ -1967,9 +2004,12 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Any& a)
{
+ SemanticGraph::Complex& c (
+ dynamic_cast<SemanticGraph::Complex&> (a.scope ()));
+
if (doxygen)
{
os << "/**" << endl
@@ -1990,7 +2030,7 @@ namespace CXX
else
{
os << "// " << ename (a) << endl
- << "// " << endl;
+ << "//" << endl;
}
// Typedefs.
@@ -2060,6 +2100,23 @@ namespace CXX
os << endl;
}
+ // Wildcard id.
+ //
+ if (ordered_p (c))
+ {
+ if (doxygen)
+ os << "/**" << endl
+ << " * @brief Wildcard id used for capturing content " <<
+ "order." << endl
+ << " */" << endl;
+
+ SemanticGraph::Context& ctx (a.context ());
+
+ os << "static const ::std::size_t " <<
+ ctx.get<String> ("ordered-id-name") << " = " <<
+ ctx.get<size_t> ("ordered-id") << "UL;" << endl;
+ }
+
any_function_.traverse (a);
if (doxygen)
@@ -2069,7 +2126,7 @@ namespace CXX
}
}
- virtual Void
+ virtual void
traverse (SemanticGraph::AnyAttribute& a)
{
String const& container (econtainer (a));
@@ -2095,7 +2152,7 @@ namespace CXX
else
{
os << "// " << ename (a) << endl
- << "// " << endl;
+ << "//" << endl;
}
if (doxygen)
@@ -2152,14 +2209,14 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& m)
{
if (skip (m)) return;
String const& member (emember (m));
- Boolean def_attr (m.default_p () &&
+ bool def_attr (m.default_p () &&
m.is_a<SemanticGraph::Attribute> ());
if (max (m) != 1)
@@ -2186,7 +2243,7 @@ namespace CXX
//
if (m.default_p ())
{
- Boolean simple (true);
+ bool simple (true);
if (m.is_a<SemanticGraph::Element> ())
{
@@ -2196,7 +2253,7 @@ namespace CXX
if (simple)
{
- Boolean lit (false);
+ bool lit (false);
{
IsLiteralValue test (lit);
test.dispatch (m.type ());
@@ -2221,7 +2278,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Any& a)
{
String const& member (emember (a));
@@ -2246,7 +2303,7 @@ namespace CXX
}
}
- virtual Void
+ virtual void
traverse (SemanticGraph::AnyAttribute& a)
{
os << econtainer (a) << " " << emember (a) << ";";
@@ -2269,15 +2326,15 @@ namespace CXX
inherits_member_ >> member_name_;
names_ >> member_;
- if (options.value<CLI::generate_wildcard> ())
+ if (options.generate_wildcard ())
names_ >> any_;
names_data_ >> data_member_;
- if (options.value<CLI::generate_wildcard> ())
+ if (options.generate_wildcard ())
names_data_ >> data_any_;
}
- virtual Void
+ virtual void
traverse (Type& c)
{
String name (ename (c));
@@ -2288,20 +2345,25 @@ namespace CXX
if (renamed_type (c, name) && !name)
return;
- Boolean has_members (has<Traversal::Member> (c));
+ SemanticGraph::Context& ctx (c.context ());
+
+ bool has_members (has<Traversal::Member> (c));
- Boolean hae (has<Traversal::Any> (c));
- Boolean haa (has<Traversal::AnyAttribute> (c));
+ bool hae (has<Traversal::Any> (c));
+ bool haa (has<Traversal::AnyAttribute> (c));
- Boolean gen_wildcard (options.value<CLI::generate_wildcard> ());
+ bool gen_wildcard (options.generate_wildcard ());
- Boolean simple (true);
+ bool mixed (mixed_p (c) && !ctx.count ("mixed-in-base"));
+ bool ordered (ordered_p (c) && !ctx.count ("order-in-base"));
+
+ bool simple (true);
{
IsSimpleType t (simple);
t.dispatch (c);
}
- Boolean string_based (false);
+ bool string_based (false);
{
IsStringBasedType t (string_based);
t.dispatch (c);
@@ -2344,17 +2406,148 @@ namespace CXX
//
names (c, names_);
- // dom_document accessors.
+ // Mixed content.
//
- if (edom_document_member_p (c))
+ if (mixed)
{
+ String const& type (ctx.get<String> ("mixed-type"));
+ String const& cont (ctx.get<String> ("mixed-container"));
+ String const& iter (ctx.get<String> ("mixed-iterator"));
+ String const& citer (ctx.get<String> ("mixed-const-iterator"));
- if (!doxygen)
- {
- os << "// DOMDocument for wildcard content." << endl
+ if (doxygen)
+ os << "/**" << endl
+ << " * @name " << comment ("text_content") << endl
+ << " *" << endl
+ << " * @brief Accessor and modifier functions for text " <<
+ "content." << endl
+ << " */" << endl
+ << "//@{" << endl;
+ else
+ os << "// text_content" << endl
<< "//" << endl;
- }
+ // Typedefs.
+ //
+ bool isense (options.generate_intellisense ());
+
+ if (doxygen)
+ os << endl
+ << "/**" << endl
+ << " * @brief Text content type." << endl
+ << " */" << endl;
+
+ os << "typedef " << xs_string_type << " " << type << ";";
+
+ if (doxygen)
+ os << endl
+ << "/**" << endl
+ << " * @brief Text content sequence container type." << endl
+ << " */" << endl;
+
+ os << "typedef ::xsd::cxx::tree::sequence< " << type <<
+ " > " << cont << ";";
+
+
+ if (doxygen)
+ os << endl
+ << "/**" << endl
+ << " * @brief Text content iterator type." << endl
+ << " */" << endl;
+
+ // IntelliSense does not like aliases and fully-qualified
+ // names here.
+ //
+ if (!isense)
+ os << "typedef " << cont << "::iterator " << iter<< ";";
+ else
+ os << "typedef ::xsd::cxx::tree::sequence< " << type <<
+ " >::iterator " << iter << ";";
+
+ if (doxygen)
+ os << endl
+ << "/**" << endl
+ << " * @brief Text content constant iterator type." << endl
+ << " */" << endl;
+
+ if (!isense)
+ os << "typedef " << cont << "::const_iterator " << citer<< ";";
+ else
+ os << "typedef ::xsd::cxx::tree::sequence< " << type <<
+ " >::const_iterator " << citer << ";";
+
+ os << endl;
+
+ // Content id.
+ //
+ if (doxygen)
+ os << "/**" << endl
+ << " * @brief Text content id used for capturing content " <<
+ "order." << endl
+ << " */" << endl;
+
+ os << "static const ::std::size_t " <<
+ ctx.get<String> ("mixed-ordered-id-name") << " = " <<
+ ctx.get<size_t> ("mixed-ordered-id") << "UL;" << endl;
+
+ // Accessors and modifiers.
+ //
+ String const& aname (ctx.get<String> ("mixed-aname"));
+ String const& mname (ctx.get<String> ("mixed-mname"));
+
+ if (doxygen)
+ os << "/**" << endl
+ << " * @brief Return a read-only (constant) reference " <<
+ "to the text" << endl
+ << " * content sequence." << endl
+ << " *" << endl
+ << " * @return A constant reference to the sequence " <<
+ "container." << endl
+ << " */" << endl;
+
+ os << "const " << cont << "&" << endl
+ << aname << " () const;"
+ << endl;
+
+ if (doxygen)
+ os << "/**" << endl
+ << " * @brief Return a read-write reference to the " <<
+ "text content" << endl
+ << " * sequence." << endl
+ << " *" << endl
+ << " * @return A reference to the sequence container." << endl
+ << " */" << endl;
+
+ os << cont << "&" << endl
+ << aname << " ();"
+ << endl;
+
+ if (doxygen)
+ os << "/**" << endl
+ << " * @brief Copy elements from a given sequence." << endl
+ << " *" << endl
+ << " * @param s A sequence to copy entries from." << endl
+ << " *" << endl
+ << " * For each element in @a s this function " <<
+ "add it to the sequence." << endl
+ << " * Note that this operation " <<
+ "completely changes the sequence and" << endl
+ << " * all old elements will be lost." << endl
+ << " */" << endl;
+
+ os << "void" << endl
+ << mname << " (const " << cont << "& s);"
+ << endl;
+
+ if (doxygen)
+ os << "//@}" << endl
+ << endl;
+ }
+
+ // dom_document accessors.
+ //
+ if (edom_document_member_p (c))
+ {
if (doxygen)
{
os << "/**" << endl
@@ -2369,6 +2562,9 @@ namespace CXX
<< " * the raw XML content corresponding to wildcards." << endl
<< " */" << endl;
}
+ else
+ os << "// DOMDocument for wildcard content." << endl
+ << "//" << endl;
os << "const " << xerces_ns << "::DOMDocument&" << endl
<< edom_document (c) << " () const;"
@@ -2393,6 +2589,137 @@ namespace CXX
<< endl;
}
+ // Order container.
+ //
+ if (ordered)
+ {
+ String const& type (ctx.get<String> ("order-type"));
+ String const& cont (ctx.get<String> ("order-container"));
+ String const& iter (ctx.get<String> ("order-iterator"));
+ String const& citer (ctx.get<String> ("order-const-iterator"));
+
+ String const ct (options.order_container_specified ()
+ ? options.order_container ()
+ : "::std::vector");
+
+ if (doxygen)
+ os << "/**" << endl
+ << " * @name " << comment ("content_order") << endl
+ << " *" << endl
+ << " * @brief Accessor and modifier functions for content " <<
+ "order." << endl
+ << " */" << endl
+ << "//@{" << endl;
+ else
+ os << "// content_order" << endl
+ << "//" << endl;
+
+ // Typedefs.
+ //
+ bool isense (options.generate_intellisense ());
+
+ if (doxygen)
+ os << endl
+ << "/**" << endl
+ << " * @brief Content order entry type." << endl
+ << " */" << endl;
+
+ os << "typedef " << ns_name (xs_ns ()) << "::" <<
+ xs_ns ().context ().get<String> ("content-order") << " " <<
+ type << ";";
+
+ if (doxygen)
+ os << endl
+ << "/**" << endl
+ << " * @brief Content order sequence container type." << endl
+ << " */" << endl;
+
+ os << "typedef " << ct << "< " << type << " > " << cont << ";";
+
+
+ if (doxygen)
+ os << endl
+ << "/**" << endl
+ << " * @brief Content order iterator type." << endl
+ << " */" << endl;
+
+ // IntelliSense does not like aliases and fully-qualified
+ // names here.
+ //
+ if (!isense)
+ os << "typedef " << cont << "::iterator " << iter<< ";";
+ else
+ os << "typedef " << ct << "< " << type << " >::iterator " <<
+ iter << ";";
+
+ if (doxygen)
+ os << endl
+ << "/**" << endl
+ << " * @brief Content order constant iterator type." << endl
+ << " */" << endl;
+
+ if (!isense)
+ os << "typedef " << cont << "::const_iterator " << citer<< ";";
+ else
+ os << "typedef " << ct << "< " << type <<
+ " >::const_iterator " << citer << ";";
+
+ os << endl;
+
+ // Accessors and modifiers.
+ //
+ String const& aname (ctx.get<String> ("order-aname"));
+ String const& mname (ctx.get<String> ("order-mname"));
+
+ if (doxygen)
+ os << "/**" << endl
+ << " * @brief Return a read-only (constant) reference " <<
+ "to the content" << endl
+ << " * order sequence." << endl
+ << " *" << endl
+ << " * @return A constant reference to the sequence " <<
+ "container." << endl
+ << " */" << endl;
+
+ os << "const " << cont << "&" << endl
+ << aname << " () const;"
+ << endl;
+
+ if (doxygen)
+ os << "/**" << endl
+ << " * @brief Return a read-write reference to the " <<
+ "content order" << endl
+ << " * sequence." << endl
+ << " *" << endl
+ << " * @return A reference to the sequence container." << endl
+ << " */" << endl;
+
+ os << cont << "&" << endl
+ << aname << " ();"
+ << endl;
+
+ if (doxygen)
+ os << "/**" << endl
+ << " * @brief Copy elements from a given sequence." << endl
+ << " *" << endl
+ << " * @param s A sequence to copy entries from." << endl
+ << " *" << endl
+ << " * For each element in @a s this function " <<
+ "add it to the sequence." << endl
+ << " * Note that this operation " <<
+ "completely changes the sequence and" << endl
+ << " * all old elements will be lost." << endl
+ << " */" << endl;
+
+ os << "void" << endl
+ << mname << " (const " << cont << "& s);"
+ << endl;
+
+ if (doxygen)
+ os << "//@}" << endl
+ << endl;
+ }
+
if (doxygen)
{
os << "/**" << endl
@@ -2407,15 +2734,15 @@ namespace CXX
<< "//" << endl;
}
- Boolean generate_no_base_ctor (false);
+ bool generate_no_base_ctor (false);
{
GenerateWithoutBaseCtor t (generate_no_base_ctor);
t.traverse (c);
}
- Boolean has_complex_non_op_args (false);
- Boolean has_poly_non_op_args (false);
- Boolean complex_poly_args_clash (true);
+ bool has_complex_non_op_args (false);
+ bool has_poly_non_op_args (false);
+ bool complex_poly_args_clash (true);
{
HasComplexPolyNonOptArgs t (*this, true,
has_complex_non_op_args,
@@ -2426,7 +2753,7 @@ namespace CXX
// default c-tor
//
- if (options.value<CLI::generate_default_ctor> ())
+ if (options.generate_default_ctor ())
{
// c-tor (ultimate-base, all-non-optional-members) will become
// default c-tor if our inheritance hierarchy has no required
@@ -2434,7 +2761,7 @@ namespace CXX
// c-tor (all-non-optional-members) if we have no required
// members.
//
- Boolean generate (false);
+ bool generate (false);
{
GenerateDefaultCtor t (*this, generate, generate_no_base_ctor);
t.traverse (c);
@@ -2460,7 +2787,7 @@ namespace CXX
// c-tor (base, all-non-optional-members)
//
- if (options.value<CLI::generate_from_base_ctor> ())
+ if (options.generate_from_base_ctor ())
{
// c-tor (base, all-non-optional-members) will be equivalent to
// c-tor (ultimate-base, all-non-optional-members) unless our
@@ -2470,7 +2797,7 @@ namespace CXX
// customized version may not necessarily be convertible to
// the base without loss of information.
//
- Boolean generate (false);
+ bool generate (false);
{
GenerateFromBaseCtor t (*this, generate);
t.traverse (c);
@@ -2478,9 +2805,9 @@ namespace CXX
if (generate)
{
- Boolean has_complex_non_op_args (false);
- Boolean has_poly_non_op_args (false);
- Boolean complex_poly_args_clash (true);
+ bool has_complex_non_op_args (false);
+ bool has_poly_non_op_args (false);
+ bool complex_poly_args_clash (true);
{
HasComplexPolyNonOptArgs t (*this, false,
has_complex_non_op_args,
@@ -2505,7 +2832,7 @@ namespace CXX
inherits (c, inherits_member_);
os << "&";
{
- FromBaseCtorArg args (*this, FromBaseCtorArg::arg_type, false);
+ FromBaseCtorArg args (*this, CtorArgType::type, false);
Traversal::Names args_names (args);
names (c, args_names);
}
@@ -2524,7 +2851,7 @@ namespace CXX
"base and" << endl
<< " * initializers for required elements and "
<< "attributes" << endl
- << " * (auto_ptr version)." << endl
+ << " * (" << auto_ptr << " version)." << endl
<< " *" << endl
<< " * This constructor will try to use the passed " <<
"values directly" << endl
@@ -2537,7 +2864,7 @@ namespace CXX
os << "&";
{
FromBaseCtorArg args (
- *this, FromBaseCtorArg::arg_complex_auto_ptr, false);
+ *this, CtorArgType::complex_auto_ptr, false);
Traversal::Names args_names (args);
names (c, args_names);
}
@@ -2558,7 +2885,7 @@ namespace CXX
"base and" << endl
<< " * initializers for required elements and "
<< "attributes" << endl
- << " * (auto_ptr version)." << endl
+ << " * (" << auto_ptr << " version)." << endl
<< " *" << endl
<< " * This constructor will try to use the passed " <<
"values directly" << endl
@@ -2571,7 +2898,7 @@ namespace CXX
os << "&";
{
FromBaseCtorArg args (
- *this, FromBaseCtorArg::arg_poly_auto_ptr, false);
+ *this, CtorArgType::poly_auto_ptr, false);
Traversal::Names args_names (args);
names (c, args_names);
}
@@ -2597,7 +2924,7 @@ namespace CXX
os << name << " (";
{
CtorArgsWithoutBase ctor_args (
- *this, CtorArgsWithoutBase::arg_type, false, true);
+ *this, CtorArgType::type, false, true);
ctor_args.dispatch (c);
}
os << ");"
@@ -2615,7 +2942,8 @@ namespace CXX
os << "/**" << endl
<< " * @brief Create an instance from initializers " <<
"for required " << endl
- << " * elements and attributes (auto_ptr version)." << endl
+ << " * elements and attributes (" << auto_ptr <<
+ " version)." << endl
<< " *" << endl
<< " * This constructor will try to use the passed " <<
"values directly" << endl
@@ -2626,7 +2954,7 @@ namespace CXX
os << name << " (";
{
CtorArgsWithoutBase ctor_args (
- *this, CtorArgsWithoutBase::arg_complex_auto_ptr, false, true);
+ *this, CtorArgType::complex_auto_ptr, false, true);
ctor_args.dispatch (c);
}
os << ");"
@@ -2644,7 +2972,8 @@ namespace CXX
os << "/**" << endl
<< " * @brief Create an instance from initializers " <<
"for required " << endl
- << " * elements and attributes (auto_ptr version)." << endl
+ << " * elements and attributes (" << auto_ptr <<
+ " version)." << endl
<< " *" << endl
<< " * This constructor will try to use the passed " <<
"values directly" << endl
@@ -2655,7 +2984,7 @@ namespace CXX
os << name << " (";
{
CtorArgsWithoutBase ctor_args (
- *this, CtorArgsWithoutBase::arg_poly_auto_ptr, false, true);
+ *this, CtorArgType::poly_auto_ptr, false, true);
ctor_args.dispatch (c);
}
os << ");"
@@ -2686,7 +3015,7 @@ namespace CXX
{
CtorArgsWithoutBase ctor_args (
- *this, CtorArgsWithoutBase::arg_type, false, false);
+ *this, CtorArgType::type, false, false);
ctor_args.dispatch (c);
}
@@ -2709,7 +3038,7 @@ namespace CXX
{
CtorArgsWithoutBase ctor_args (
- *this, CtorArgsWithoutBase::arg_type, false, false);
+ *this, CtorArgType::type, false, false);
ctor_args.dispatch (c);
}
@@ -2731,7 +3060,7 @@ namespace CXX
{
CtorArgsWithoutBase ctor_args (
- *this, CtorArgsWithoutBase::arg_type, false, false);
+ *this, CtorArgType::type, false, false);
ctor_args.dispatch (c);
}
@@ -2755,7 +3084,7 @@ namespace CXX
os << name << " (";
{
- CtorArgs ctor_args (*this, CtorArgs::arg_type);
+ CtorArgs ctor_args (*this, CtorArgType::type);
ctor_args.dispatch (c);
}
@@ -2774,7 +3103,7 @@ namespace CXX
"base and" << endl
<< " * initializers for required elements and " <<
"attributes" << endl
- << " * (auto_ptr version)." << endl
+ << " * (" << auto_ptr << " version)." << endl
<< " *" << endl
<< " * This constructor will try to use the passed " <<
"values directly" << endl
@@ -2785,7 +3114,7 @@ namespace CXX
os << name << " (";
{
- CtorArgs ctor_args (*this, CtorArgs::arg_complex_auto_ptr);
+ CtorArgs ctor_args (*this, CtorArgType::complex_auto_ptr);
ctor_args.dispatch (c);
}
@@ -2805,7 +3134,7 @@ namespace CXX
"base and" << endl
<< " * initializers for required elements and " <<
"attributes" << endl
- << " * (auto_ptr version)." << endl
+ << " * (" << auto_ptr << " version)." << endl
<< " *" << endl
<< " * This constructor will try to use the passed " <<
"values directly" << endl
@@ -2816,7 +3145,7 @@ namespace CXX
os << name << " (";
{
- CtorArgs ctor_args (*this, CtorArgs::arg_poly_auto_ptr);
+ CtorArgs ctor_args (*this, CtorArgType::poly_auto_ptr);
ctor_args.dispatch (c);
}
@@ -2826,8 +3155,9 @@ namespace CXX
// c-tor (istream&)
//
- Streams const& st (options.value<CLI::generate_extraction> ());
- for (Streams::ConstIterator i (st.begin ()); i != st.end (); ++i)
+ NarrowStrings const& st (options.generate_extraction ());
+ for (NarrowStrings::const_iterator i (st.begin ()); i != st.end ();
+ ++i)
{
if (doxygen)
{
@@ -2852,7 +3182,7 @@ namespace CXX
}
- if (!options.value<CLI::suppress_parsing> ())
+ if (!options.suppress_parsing ())
{
// c-tor (xercesc::DOMElement)
//
@@ -2969,12 +3299,61 @@ namespace CXX
<< container << "* c = 0) const;"
<< endl;
+ // operator=
+ //
+ bool priv (false);
+
+ if (!simple)
+ {
+ if (options.suppress_assignment ())
+ {
+ priv = true;
+ os << "private:" << endl;
+
+ if (doxygen)
+ {
+ os << "/**" << endl
+ << " * @brief Disabled copy assignment operator." << endl
+ << " *" << endl
+ << " * @param x An instance to make a copy of." << endl
+ << " * @return A reference to itself." << endl
+ << " */" << endl;
+ }
+
+ os << name << "&" << endl
+ << "operator= (const " << name << "& x);"
+ << endl;
+ }
+ else if (has_members || (gen_wildcard && (hae || haa)))
+ {
+ if (doxygen)
+ {
+ os << "/**" << endl
+ << " * @brief Copy assignment operator." << endl
+ << " *" << endl
+ << " * @param x An instance to make a copy of." << endl
+ << " * @return A reference to itself." << endl
+ << " *" << endl
+ << " * For polymorphic object models use the @c _clone " <<
+ "function instead." << endl
+ << " */" << endl;
+ }
+
+ os << name << "&" << endl
+ << "operator= (const " << name << "& x);"
+ << endl;
+ }
+ }
+
if (doxygen)
{
os << "//@}" << endl
<< endl;
}
+ if (priv)
+ os << "public:" << endl;
+
// d-tor
//
if (doxygen)
@@ -2990,7 +3369,7 @@ namespace CXX
// Data members and implementation functions.
//
- if (has_members || hae || (haa && gen_wildcard))
+ if (has_members || hae || (haa && gen_wildcard) || ordered || mixed)
{
os << "// Implementation." << endl
<< "//" << endl;
@@ -3000,9 +3379,10 @@ namespace CXX
<< "//@cond" << endl
<< endl;
- if (!options.value<CLI::suppress_parsing> ())
+ if (!options.suppress_parsing () &&
+ (has_members || hae || (haa && gen_wildcard) || mixed))
{
- // parse (xercesc::DOMElement)
+ // parse ()
//
os << "protected:" << endl
<< "void" << endl
@@ -3019,7 +3399,8 @@ namespace CXX
//
if (has_members)
{
- for (Streams::ConstIterator i (st.begin ()); i != st.end (); ++i)
+ for (NarrowStrings::const_iterator i (st.begin ()); i != st.end ();
+ ++i)
{
os << "void" << endl
<< unclash (name, "parse") << " (" <<
@@ -3029,7 +3410,7 @@ namespace CXX
}
}
- //
+ // DOM document.
//
if (edom_document_member_p (c))
{
@@ -3038,6 +3419,24 @@ namespace CXX
<< endl;
}
+ // Mixed text content.
+ //
+ if (mixed)
+ {
+ os << ctx.get<String> ("mixed-container") << " " <<
+ ctx.get<String> ("mixed-member") << ";"
+ << endl;
+ }
+
+ // Order container.
+ //
+ if (ordered)
+ {
+ os << ctx.get<String> ("order-container") << " " <<
+ ctx.get<String> ("order-member") << ";"
+ << endl;
+ }
+
//
//
names (c, names_data_);
@@ -3051,7 +3450,7 @@ namespace CXX
// Comparison operators.
//
- if (options.value<CLI::generate_comparison> () &&
+ if (options.generate_comparison () &&
(has_members || !c.inherits_p () ||
((hae || haa) && gen_wildcard)))
{
@@ -3095,7 +3494,7 @@ namespace CXX
belongs_ >> type_name_;
}
- virtual Void
+ virtual void
traverse (Type& e)
{
if (!doc_root_p (e))
@@ -3103,13 +3502,13 @@ namespace CXX
SemanticGraph::Type& t (e.type ());
- Boolean fund (false);
+ bool fund (false);
{
IsFundamentalType test (fund);
test.dispatch (t);
}
- Boolean simple (true);
+ bool simple (true);
if (!fund)
{
IsSimpleType test (simple);
@@ -3274,7 +3673,7 @@ namespace CXX
}
os << "void" << endl
- << mname << " (::std::auto_ptr< " << type << " > p);"
+ << mname << " (" << auto_ptr << "< " << type << " > p);"
<< endl;
}
@@ -3296,7 +3695,7 @@ namespace CXX
<< " */" << endl;
}
- os << "::std::auto_ptr< " << type << " >" << endl
+ os << auto_ptr << "< " << type << " >" << endl
<< edname (e) << " ();"
<< endl;
}
@@ -3357,7 +3756,7 @@ namespace CXX
// default c-tor
//
- if (options.value<CLI::generate_default_ctor> ())
+ if (options.generate_default_ctor ())
{
if (doxygen)
{
@@ -3403,7 +3802,8 @@ namespace CXX
os << "/**" << endl
<< " * @brief Create an instance from an initializer " <<
"for" << endl
- << " * the element value (auto_ptr version)." << endl
+ << " * the element value (" << auto_ptr <<
+ " version)." << endl
<< " *" << endl
<< " * @param p Element value to use." << endl
<< " *" << endl
@@ -3413,11 +3813,11 @@ namespace CXX
<< " */" << endl;
}
- os << name << " (::std::auto_ptr< " << type << " > p);"
+ os << name << " (" << auto_ptr << "< " << type << " > p);"
<< endl;
}
- if (!options.value<CLI::suppress_parsing> ())
+ if (!options.suppress_parsing ())
{
// c-tor (xercesc::DOMElement)
//
@@ -3608,7 +4008,7 @@ namespace CXX
};
}
- Void
+ void
generate_tree_header (Context& ctx)
{
if (ctx.generate_xml_schema)
@@ -3625,21 +4025,21 @@ namespace CXX
<< "#include <xsd/cxx/tree/types.hxx>" << endl
<< endl;
- if (!ctx.options.value<CLI::suppress_parsing> () ||
- ctx.options.value<CLI::generate_serialization> ())
+ if (!ctx.options.suppress_parsing () ||
+ ctx.options.generate_serialization ())
{
ctx.os << "#include <xsd/cxx/xml/error-handler.hxx>" << endl
<< endl;
}
- if (!ctx.options.value<CLI::suppress_parsing> () ||
- ctx.options.value<CLI::generate_serialization> ())
+ if (!ctx.options.suppress_parsing () ||
+ ctx.options.generate_serialization ())
{
ctx.os << "#include <xsd/cxx/xml/dom/auto-ptr.hxx>" << endl
<< endl;
}
- Boolean element_map (ctx.options.value<CLI::generate_element_map> ());
+ bool element_map (ctx.options.generate_element_map ());
if (element_map)
ctx.os << "#include <xsd/cxx/tree/element-map.hxx>" << endl
@@ -3649,7 +4049,7 @@ namespace CXX
// later in the individual generators for each feature because
// those headers provide implementation for the fundamental types.
//
- if (!ctx.options.value<CLI::suppress_parsing> ())
+ if (!ctx.options.suppress_parsing ())
{
ctx.os << "#include <xsd/cxx/tree/parsing.hxx>" << endl;
@@ -3670,7 +4070,7 @@ namespace CXX
ctx.os << endl;
}
- if (ctx.options.value<CLI::generate_serialization> ())
+ if (ctx.options.generate_serialization ())
{
ctx.os << "#include <xsd/cxx/xml/dom/serialization-header.hxx>" << endl
<< "#include <xsd/cxx/tree/serialization.hxx>" << endl;
@@ -3692,16 +4092,17 @@ namespace CXX
ctx.os << endl;
}
- if (ctx.options.value<CLI::generate_ostream> ())
+ if (ctx.options.generate_ostream ())
{
ctx.os << "#include <xsd/cxx/tree/std-ostream-operators.hxx>" << endl
<< endl;
}
- Streams const& ist (ctx.options.value<CLI::generate_insertion> ());
+ NarrowStrings const& ist (ctx.options.generate_insertion ());
if (!ist.empty ())
{
- for (Streams::ConstIterator i (ist.begin ()); i != ist.end (); ++i)
+ for (NarrowStrings::const_iterator i (ist.begin ()); i != ist.end ();
+ ++i)
{
if (*i == "ACE_OutputCDR")
ctx.os << "#include <xsd/cxx/tree/ace-cdr-stream-insertion.hxx>"
@@ -3715,10 +4116,11 @@ namespace CXX
<< endl;
}
- Streams const& est (ctx.options.value<CLI::generate_extraction> ());
+ NarrowStrings const& est (ctx.options.generate_extraction ());
if (!est.empty ())
{
- for (Streams::ConstIterator i (est.begin ()); i != est.end (); ++i)
+ for (NarrowStrings::const_iterator i (est.begin ()); i != est.end ();
+ ++i)
{
if (*i == "ACE_InputCDR")
ctx.os << "#include <xsd/cxx/tree/ace-cdr-stream-extraction.hxx>"
@@ -3746,12 +4148,25 @@ namespace CXX
}
else
{
- Boolean inline_ (ctx.options.value<CLI::generate_inline> ());
+ bool inline_ (ctx.options.generate_inline ());
- ctx.os << "#include <memory> // std::auto_ptr" << endl
+ ctx.os << "#include <memory> // " << ctx.auto_ptr << endl
<< "#include <limits> // std::numeric_limits" << endl
- << "#include <algorithm> // std::binary_search" << endl
- << endl;
+ << "#include <algorithm> // std::binary_search" << endl;
+
+ if (ctx.std >= cxx_version::cxx11)
+ ctx.os << "#include <utility> // std::move" << endl;
+
+ if (!ctx.options.ordered_type ().empty () ||
+ ctx.options.ordered_type_all ())
+ {
+ ctx.os << "#include <cstddef> // std::size_t" << endl;
+
+ if (!ctx.options.order_container_specified ())
+ ctx.os << "#include <vector>" << endl;
+ }
+
+ ctx.os << endl;
if (ctx.char_type == L"char" && ctx.char_encoding != L"custom")
{
@@ -3766,23 +4181,23 @@ namespace CXX
<< "#include <xsd/cxx/tree/list.hxx>" << endl
<< endl;
- if (!ctx.options.value<CLI::suppress_parsing> ())
+ if (!ctx.options.suppress_parsing ())
{
ctx.os << "#include <xsd/cxx/xml/dom/parsing-header.hxx>" << endl
<< endl;
}
- if (ctx.options.value<CLI::generate_wildcard> ())
+ if (ctx.options.generate_wildcard ())
{
- if (ctx.options.value<CLI::suppress_parsing> () ||
- !ctx.options.value<CLI::generate_serialization> ())
+ if (ctx.options.suppress_parsing () ||
+ !ctx.options.generate_serialization ())
ctx.os << "#include <xsd/cxx/xml/dom/auto-ptr.hxx>" << endl;
ctx.os << "#include <xsd/cxx/tree/containers-wildcard.hxx>" << endl
<< endl;
}
- if (!ctx.options.value<CLI::generate_extraction> ().empty ())
+ if (!ctx.options.generate_extraction ().empty ())
ctx.os << "#include <xsd/cxx/tree/istream-fwd.hxx>" << endl
<< endl;
@@ -3820,7 +4235,7 @@ namespace CXX
{
Traversal::Schema schema;
- Traversal::Sources sources;
+ Sources sources;
Traversal::Names names_ns, names;
DocumentedNamespace ns (ctx);
@@ -3839,7 +4254,7 @@ namespace CXX
names >> complex;
names >> enumeration;
- if (ctx.options.value<CLI::generate_element_type> ())
+ if (ctx.options.generate_element_type ())
names >> element;
schema.dispatch (ctx.schema_root);
diff --git a/xsd/xsd/cxx/tree/tree-header.hxx b/xsd/xsd/cxx/tree/tree-header.hxx
index bb3b417..7c97364 100644
--- a/xsd/xsd/cxx/tree/tree-header.hxx
+++ b/xsd/xsd/cxx/tree/tree-header.hxx
@@ -1,6 +1,5 @@
// file : xsd/cxx/tree/tree-header.hxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#ifndef CXX_TREE_TREE_HEADER_HXX
@@ -12,7 +11,7 @@ namespace CXX
{
namespace Tree
{
- Void
+ void
generate_tree_header (Context&);
}
}
diff --git a/xsd/xsd/cxx/tree/tree-inline.cxx b/xsd/xsd/cxx/tree/tree-inline.cxx
index 5bf309b..500ee73 100644
--- a/xsd/xsd/cxx/tree/tree-inline.cxx
+++ b/xsd/xsd/cxx/tree/tree-inline.cxx
@@ -1,6 +1,5 @@
// file : xsd/cxx/tree/tree-inline.cxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#include <xsd-frontend/semantic-graph.hxx>
@@ -22,7 +21,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& l)
{
String name (ename (l));
@@ -54,7 +53,7 @@ namespace CXX
os << inl
<< name << "::" << endl
<< name << " ()" << endl
- << ": " << base_type << " ( " << flags_type << " (0), this)"
+ << ": " << base_type << " (this)"
<< "{"
<< "}";
@@ -83,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:
@@ -106,7 +127,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& u)
{
String name (ename (u));
@@ -123,7 +144,7 @@ namespace CXX
<< "//" << endl
<< endl;
- if (options.value<CLI::generate_default_ctor> ())
+ if (options.generate_default_ctor ())
{
// c-tor ()
//
@@ -182,7 +203,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Complex& c)
{
// This type should be ultimately string based.
@@ -196,7 +217,7 @@ namespace CXX
os << ")";
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Type& t)
{
base_type_name_.dispatch (t);
@@ -217,7 +238,7 @@ namespace CXX
inherits_member_ >> member_;
}
- virtual Void
+ virtual void
traverse (Type& e)
{
String name (ename (e));
@@ -228,13 +249,13 @@ namespace CXX
if (renamed_type (e, name) && !name)
return;
- Boolean string_based (false);
+ bool string_based (false);
{
IsStringBasedType t (string_based);
t.dispatch (e);
}
- Boolean enum_based (false);
+ bool enum_based (false);
if (string_based)
{
SemanticGraph::Enumeration* be (0);
@@ -250,7 +271,7 @@ namespace CXX
// Get to the ultimate base and see if is a fundamental type.
//
- Boolean fund_based (false);
+ bool fund_based (false);
SemanticGraph::Type& ult_base (ultimate_base (e));
{
IsFundamentalType t (fund_based);
@@ -276,7 +297,7 @@ namespace CXX
// default c-tor
//
- if (options.value<CLI::generate_default_ctor> ())
+ if (options.generate_default_ctor ())
{
os << inl
<< name << "::" << endl
@@ -427,7 +448,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& m)
{
if (skip (m))
@@ -437,13 +458,13 @@ namespace CXX
String const& mname (emname (m));
String const& member (emember (m));
- Boolean fund (false);
+ bool fund (false);
{
IsFundamentalType t (fund);
t.dispatch (m.type ());
}
- Boolean def_attr (m.default_p () &&
+ bool def_attr (m.default_p () &&
m.is_a<SemanticGraph::Attribute> ());
if (max (m) != 1)
@@ -537,9 +558,10 @@ namespace CXX
if (!fund)
os << inl
<< "void " << scope_ << "::" << endl
- << mname << " (::std::auto_ptr< " << type << " > x)"
+ << mname << " (" << auto_ptr << "< " << type << " > x)"
<< "{"
- << "this->" << member << ".set (x);"
+ << "this->" << member << ".set (" <<
+ (std >= cxx_version::cxx11 ? "std::move (x)" : "x") << ");"
<< "}";
}
else
@@ -589,9 +611,10 @@ namespace CXX
if (!fund)
os << inl
<< "void " << scope_ << "::" << endl
- << mname << " (::std::auto_ptr< " << type << " > x)"
+ << mname << " (" << auto_ptr << "< " << type << " > x)"
<< "{"
- << "this->" << member << ".set (x);"
+ << "this->" << member << ".set (" <<
+ (std >= cxx_version::cxx11 ? "std::move (x)" : "x") << ");"
<< "}";
// auto_ptr<type>
@@ -599,7 +622,7 @@ namespace CXX
//
if (detach && !fund)
os << inl
- << "::std::auto_ptr< " << q_type << " > " <<
+ << auto_ptr << "< " << q_type << " > " <<
scope_ << "::" << endl
<< edname (m) << " ()"
<< "{"
@@ -613,7 +636,7 @@ namespace CXX
//
if (m.default_p ())
{
- Boolean simple (true);
+ bool simple (true);
if (m.is_a<SemanticGraph::Element> ())
{
@@ -660,7 +683,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Any& a)
{
String const& aname (eaname (a));
@@ -810,7 +833,7 @@ namespace CXX
}
}
- virtual Void
+ virtual void
traverse (SemanticGraph::AnyAttribute& a)
{
String const& aname (eaname (a));
@@ -862,7 +885,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& c)
{
String name (ename (c));
@@ -883,13 +906,48 @@ namespace CXX
Member member (*this, name);
Traversal::Names names;
- if (options.value<CLI::generate_wildcard> ())
+ if (options.generate_wildcard ())
names >> any;
names >> member;
Complex::names (c, names);
+ // Mixed text content.
+ //
+ if (mixed_p (c) && !c.context ().count ("mixed-in-base"))
+ {
+ SemanticGraph::Context& ctx (c.context ());
+
+ String const& cont (ctx.get<String> ("mixed-container"));
+ String const& memb (ctx.get<String> ("mixed-member"));
+
+ String const& aname (ctx.get<String> ("mixed-aname"));
+ String const& mname (ctx.get<String> ("mixed-mname"));
+
+ os << inl
+ << "const " << name << "::" << cont << "& " <<
+ name << "::" << endl
+ << aname << " () const"
+ << "{"
+ << "return this->" << memb << ";"
+ << "}";
+
+ os << inl
+ << name << "::" << cont << "& " << name << "::" << endl
+ << aname << " ()"
+ << "{"
+ << "return this->" << memb << ";"
+ << "}";
+
+ os << inl
+ << "void " << name << "::" << endl
+ << mname << " (const " << cont << "& s)"
+ << "{"
+ << "this->" << memb << " = s;"
+ << "}";
+ }
+
// dom_document accessors.
//
if (edom_document_member_p (c))
@@ -899,14 +957,49 @@ namespace CXX
name << "::" << endl
<< edom_document (c) << " () const"
<< "{"
- << "return *" << edom_document_member (c) << ";"
+ << "return *this->" << edom_document_member (c) << ";"
<< "}";
os << inl
<< xerces_ns << "::DOMDocument& " << name << "::" << endl
<< edom_document (c) << " ()"
<< "{"
- << "return *" << edom_document_member (c) << ";"
+ << "return *this->" << edom_document_member (c) << ";"
+ << "}";
+ }
+
+ // Order container.
+ //
+ if (ordered_p (c) && !c.context ().count ("order-in-base"))
+ {
+ SemanticGraph::Context& ctx (c.context ());
+
+ String const& cont (ctx.get<String> ("order-container"));
+ String const& memb (ctx.get<String> ("order-member"));
+
+ String const& aname (ctx.get<String> ("order-aname"));
+ String const& mname (ctx.get<String> ("order-mname"));
+
+ os << inl
+ << "const " << name << "::" << cont << "& " <<
+ name << "::" << endl
+ << aname << " () const"
+ << "{"
+ << "return this->" << memb << ";"
+ << "}";
+
+ os << inl
+ << name << "::" << cont << "& " << name << "::" << endl
+ << aname << " ()"
+ << "{"
+ << "return this->" << memb << ";"
+ << "}";
+
+ os << inl
+ << "void " << name << "::" << endl
+ << mname << " (const " << cont << "& s)"
+ << "{"
+ << "this->" << memb << " = s;"
<< "}";
}
@@ -924,13 +1017,13 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& e)
{
if (!doc_root_p (e))
return;
- Boolean fund (false);
+ bool fund (false);
{
IsFundamentalType test (fund);
test.dispatch (e.type ());
@@ -976,7 +1069,7 @@ namespace CXX
<< "void " << name << "::" << endl
<< mname << " (const " << type << "& x)"
<< "{"
- << "return this->" << member << ".set (x);"
+ << "this->" << member << ".set (x);"
<< "}";
// void
@@ -986,9 +1079,10 @@ namespace CXX
{
os << inl
<< "void " << name << "::" << endl
- << mname << " (::std::auto_ptr< " << type << " > p)"
+ << mname << " (" << auto_ptr << "< " << type << " > x)"
<< "{"
- << "return this->" << member << ".set (p);"
+ << "this->" << member << ".set (" <<
+ (std >= cxx_version::cxx11 ? "std::move (x)" : "x") << ");"
<< "}";
}
@@ -997,7 +1091,7 @@ namespace CXX
//
if (detach && !fund)
os << inl
- << "::std::auto_ptr< " << name << "::" << type << " > " <<
+ << auto_ptr << "< " << name << "::" << type << " > " <<
name << "::" << endl
<< edname (e) << " ()"
<< "{"
@@ -1007,12 +1101,12 @@ namespace CXX
};
}
- Void
- generate_tree_inline (Context& ctx, UnsignedLong first, UnsignedLong last)
+ void
+ generate_tree_inline (Context& ctx, size_t first, size_t last)
{
// Generate includes.
//
- if (ctx.options.value<CLI::generate_inline> ())
+ if (ctx.options.generate_inline ())
{
Traversal::Schema schema;
Includes includes (ctx, Includes::inline_);
@@ -1035,7 +1129,7 @@ namespace CXX
}
Traversal::Schema schema;
- Traversal::Sources sources;
+ Sources sources;
Traversal::Names names_ns, names;
Namespace ns (ctx, first, last);
@@ -1053,7 +1147,7 @@ namespace CXX
names >> complex;
names >> enumeration;
- if (ctx.options.value<CLI::generate_element_type> ())
+ if (ctx.options.generate_element_type ())
names >> element;
schema.dispatch (ctx.schema_root);
diff --git a/xsd/xsd/cxx/tree/tree-inline.hxx b/xsd/xsd/cxx/tree/tree-inline.hxx
index ffe4341..351ab38 100644
--- a/xsd/xsd/cxx/tree/tree-inline.hxx
+++ b/xsd/xsd/cxx/tree/tree-inline.hxx
@@ -1,6 +1,5 @@
// file : xsd/cxx/tree/tree-inline.hxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#ifndef CXX_TREE_TREE_INLINE_HXX
@@ -12,8 +11,8 @@ namespace CXX
{
namespace Tree
{
- Void
- generate_tree_inline (Context&, UnsignedLong first, UnsignedLong last);
+ void
+ generate_tree_inline (Context&, size_t first, size_t last);
}
}
diff --git a/xsd/xsd/cxx/tree/tree-source.cxx b/xsd/xsd/cxx/tree/tree-source.cxx
index 4a17b00..8a01c5a 100644
--- a/xsd/xsd/cxx/tree/tree-source.cxx
+++ b/xsd/xsd/cxx/tree/tree-source.cxx
@@ -1,9 +1,9 @@
// file : xsd/cxx/tree/tree-source.cxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
-#include <cult/containers/list.hxx>
+#include <map>
+#include <list>
#include <xsd-frontend/semantic-graph.hxx>
#include <xsd-frontend/traversal.hxx>
@@ -11,6 +11,8 @@
#include <cxx/tree/tree-source.hxx>
#include <cxx/tree/default-value.hxx>
+using namespace std;
+
namespace CXX
{
namespace Tree
@@ -24,7 +26,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& l)
{
String name (ename (l));
@@ -39,7 +41,7 @@ namespace CXX
<< "//" << endl
<< endl;
- if (!options.value<CLI::suppress_parsing> ())
+ if (!options.suppress_parsing ())
{
SemanticGraph::Type& item_type (l.argumented ().type ());
String base (L"::xsd::cxx::tree::list< " +
@@ -105,27 +107,35 @@ namespace CXX
// Register with type factory map.
//
- if (polymorphic && polymorphic_p (l) && !anonymous_p (l))
+ if (polymorphic && polymorphic_p (l))
{
// Note that we are using the original type name.
//
String const& name (ename (l));
- if (!options.value<CLI::suppress_parsing> ())
+ // If this type is anonymous but substitutes, then it will
+ // be registered as part of the substitution registration.
+ //
+ if (!anonymous_p (l) && !options.suppress_parsing ())
+ {
os << "static" << endl
- << "const ::xsd::cxx::tree::type_factory_initializer< 0, " <<
- char_type << ", " << name << " >" << endl
+ << "const ::xsd::cxx::tree::type_factory_initializer< " <<
+ poly_plate << ", " << char_type << ", " << name << " >" << endl
<< "_xsd_" << name << "_type_factory_init (" << endl
<< strlit (l.name ()) << "," << endl
<< strlit (xml_ns_name (l)) << ");"
<< endl;
+ }
- if (options.value<CLI::generate_comparison> ())
+ if ((!anonymous_p (l) || anonymous_substitutes_p (l)) &&
+ options.generate_comparison ())
+ {
os << "static" << endl
- << "const ::xsd::cxx::tree::comparison_initializer< 0, " <<
- char_type << ", " << name << " >" << endl
+ << "const ::xsd::cxx::tree::comparison_initializer< " <<
+ poly_plate << ", " << char_type << ", " << name << " >" << endl
<< "_xsd_" << name << "_comparison_init;"
<< endl;
+ }
}
}
@@ -150,7 +160,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& u)
{
String name (ename (u));
@@ -167,7 +177,7 @@ namespace CXX
<< "//" << endl
<< endl;
- if (!options.value<CLI::suppress_parsing> ())
+ if (!options.suppress_parsing ())
{
// c-tor (xercesc::DOMElement)
//
@@ -212,27 +222,35 @@ namespace CXX
// Register with type factory map.
//
- if (polymorphic && polymorphic_p (u) && !anonymous_p (u))
+ if (polymorphic && polymorphic_p (u))
{
// Note that we are using the original type name.
//
String const& name (ename (u));
- if (!options.value<CLI::suppress_parsing> ())
+ // If this type is anonymous but substitutes, then it will
+ // be registered as part of the substitution registration.
+ //
+ if (!anonymous_p (u) && !options.suppress_parsing ())
+ {
os << "static" << endl
- << "const ::xsd::cxx::tree::type_factory_initializer< 0, " <<
- char_type << ", " << name << " >" << endl
+ << "const ::xsd::cxx::tree::type_factory_initializer< " <<
+ poly_plate << ", " << char_type << ", " << name << " >" << endl
<< "_xsd_" << name << "_type_factory_init (" << endl
<< strlit (u.name ()) << "," << endl
<< strlit (xml_ns_name (u)) << ");"
<< endl;
+ }
- if (options.value<CLI::generate_comparison> ())
+ if ((!anonymous_p (u) || anonymous_substitutes_p (u)) &&
+ options.generate_comparison ())
+ {
os << "static" << endl
- << "const ::xsd::cxx::tree::comparison_initializer< 0, " <<
- char_type << ", " << name << " >" << endl
+ << "const ::xsd::cxx::tree::comparison_initializer< " <<
+ poly_plate << ", " << char_type << ", " << name << " >" << endl
<< "_xsd_" << name << "_comparison_init;"
<< endl;
+ }
}
}
};
@@ -248,7 +266,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& e)
{
os << strlit (e.name ());
@@ -269,13 +287,13 @@ namespace CXX
String name_;
};
- Boolean
+ bool
operator< (LiteralInfo const& x, LiteralInfo const& y)
{
return x.value_ < y.value_;
}
- typedef Cult::Containers::List<LiteralInfo> LiteralInfoList;
+ typedef list<LiteralInfo> LiteralInfoList;
// Populate LiteralInfoList
@@ -288,7 +306,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& e)
{
list_.push_back (LiteralInfo (e.name (), ename (e)));
@@ -307,7 +325,7 @@ namespace CXX
names_enumerator_literal_ >> enumerator_literal_;
}
- virtual Void
+ virtual void
traverse (Type& e)
{
String name (ename (e));
@@ -318,14 +336,14 @@ namespace CXX
if (renamed_type (e, name) && !name)
return;
- Boolean string_based (false);
+ bool string_based (false);
{
IsStringBasedType t (string_based);
t.dispatch (e);
}
SemanticGraph::Enumeration* be (0);
- Boolean enum_based (false);
+ bool enum_based (false);
if (string_based)
{
IsEnumBasedType t (be);
@@ -338,7 +356,7 @@ namespace CXX
if (string_based)
value = evalue (e);
- UnsignedLong enum_count (0);
+ size_t enum_count (0);
for (Type::NamesIterator i (e.names_begin ()), end (e.names_end ());
i != end; ++i)
@@ -359,7 +377,7 @@ namespace CXX
<< "//" << endl
<< endl;
- if (!options.value<CLI::suppress_parsing> ())
+ if (!options.suppress_parsing ())
{
// c-tor (xercesc::DOMElement)
//
@@ -490,7 +508,7 @@ namespace CXX
String fq_name (ns_scope + L"::" + name);
- for (LiteralInfoList::Iterator
+ for (LiteralInfoList::iterator
b (l.begin ()), i (b), end (l.end ()); i != end; ++i)
{
if (i != b)
@@ -504,31 +522,39 @@ namespace CXX
// Register with type factory map.
//
- if (polymorphic && polymorphic_p (e) && !anonymous_p (e))
+ if (polymorphic && polymorphic_p (e))
{
// Note that we are using the original type name.
//
String const& name (ename (e));
- if (!options.value<CLI::suppress_parsing> ())
+ // If this type is anonymous but substitutes, then it will
+ // be registered as part of the substitution registration.
+ //
+ if (!anonymous_p (e) && !options.suppress_parsing ())
+ {
os << "static" << endl
- << "const ::xsd::cxx::tree::type_factory_initializer< 0, " <<
- char_type << ", " << name << " >" << endl
+ << "const ::xsd::cxx::tree::type_factory_initializer< " <<
+ poly_plate << ", " << char_type << ", " << name << " >" << endl
<< "_xsd_" << name << "_type_factory_init (" << endl
<< strlit (e.name ()) << "," << endl
<< strlit (xml_ns_name (e)) << ");"
<< endl;
+ }
- if (options.value<CLI::generate_comparison> ())
+ if ((!anonymous_p (e) || anonymous_substitutes_p (e)) &&
+ options.generate_comparison ())
+ {
os << "static" << endl
- << "const ::xsd::cxx::tree::comparison_initializer< 0, " <<
- char_type << ", " << name << " >" << endl
+ << "const ::xsd::cxx::tree::comparison_initializer< " <<
+ poly_plate << ", " << char_type << ", " << name << " >" << endl
<< "_xsd_" << name << "_comparison_init;"
<< endl;
+ }
}
}
- virtual Void
+ virtual void
comma (Type&)
{
os << "," << endl;
@@ -549,7 +575,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& m)
{
if (skip (m))
@@ -560,7 +586,7 @@ namespace CXX
if (m.default_p ())
{
SemanticGraph::Type& t (m.type ());
- Boolean simple (true);
+ bool simple (true);
if (m.is_a<SemanticGraph::Element> ())
{
@@ -570,7 +596,7 @@ namespace CXX
if (simple)
{
- Boolean lit (false);
+ bool lit (false);
{
IsLiteralValue test (lit);
test.dispatch (t);
@@ -661,12 +687,15 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& e)
{
if (skip (e))
return;
+ SemanticGraph::Complex& c (
+ dynamic_cast<SemanticGraph::Complex&> (e.scope ()));
+
String const& member (emember (e));
String tr (etraits (e)); // traits type name
@@ -674,7 +703,7 @@ namespace CXX
SemanticGraph::Type& t (e.type ());
- Boolean fund (false);
+ bool fund (false);
{
IsFundamentalType traverser (fund);
traverser.dispatch (t);
@@ -686,23 +715,17 @@ namespace CXX
// derived from which makes it impossible to substitute or
// dynamically-type with xsi:type.
//
- Boolean poly (polymorphic && polymorphic_p (t) && !anonymous_p (t));
+ bool poly (polymorphic && polymorphic_p (t) && !anonymous_p (t));
os << "// " << comment (e.name ()) << endl
<< "//" << endl;
if (poly)
{
- // aCC cannot handle an inline call to type_factory_map_instance.
- //
os << "{"
- << "::xsd::cxx::tree::type_factory_map< " << char_type <<
- " >& tfm (" << endl
- << "::xsd::cxx::tree::type_factory_map_instance< 0, " <<
- char_type << " > ());"
- << endl
- << "::std::auto_ptr< ::xsd::cxx::tree::type > tmp (" << endl
- << "tfm.create (" << endl
+ << auto_ptr << "< ::xsd::cxx::tree::type > tmp (" << endl
+ << "::xsd::cxx::tree::type_factory_map_instance< " <<
+ poly_plate << ", " << char_type << " > ().create (" << endl
<< strlit (e.name ()) << "," << endl
<< (e.qualified_p ()
? strlit (e.namespace_ ().name ())
@@ -732,8 +755,14 @@ namespace CXX
if (!fund)
{
- os << "::std::auto_ptr< " << type << " > r (" << endl
- << tr << "::create (i, f, this));"
+ os << auto_ptr << "< " << type << " > r (" << endl
+ << tr << "::create (i, f";
+
+ if (t.is_a<SemanticGraph::AnyType> () &&
+ options.generate_any_type ())
+ os << " | " << flags_type << "::extract_content";
+
+ os << ", this));"
<< endl;
}
}
@@ -772,7 +801,7 @@ namespace CXX
{
// Cast to static type.
//
- os << "::std::auto_ptr< " << type << " > r (" << endl
+ os << auto_ptr << "< " << type << " > r (" << endl
<< "dynamic_cast< " << type << "* > (tmp.get ()));"
<< endl
<< "if (r.get ())" << endl
@@ -783,23 +812,25 @@ namespace CXX
<< endl;
}
+ char const* r (std >= cxx_version::cxx11 ? "::std::move (r)" : "r");
+
if (max (e) != 1)
{
// sequence
//
- os << "this->" << member << ".push_back (r);";
+ os << "this->" << member << ".push_back (" << r << ");";
}
else if (min (e) == 0)
{
// optional
//
- os << "this->" << member << ".set (r);";
+ os << "this->" << member << ".set (" << r << ");";
}
else
{
// one
//
- os << "this->" << member << ".set (r);";
+ os << "this->" << member << ".set (" << r << ");";
}
}
else
@@ -827,6 +858,27 @@ namespace CXX
}
}
+ // Capture order.
+ //
+ if (ordered_p (c))
+ {
+ SemanticGraph::Context& ctx (c.context ());
+
+ String const& t (ctx.get<String> ("order-type"));
+ String const& m (ctx.get<String> ("order-member"));
+
+ os << "this->" << m << ".push_back (" << endl
+ << t << " (" <<
+ e.context ().get<String> ("ordered-id-name");
+
+ // sequence
+ //
+ if (max (e) != 1)
+ os << ", " << "this->" << member << ".size () - 1";
+
+ os << "));";
+ }
+
os << "continue;";
// End of check block.
@@ -863,7 +915,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& e)
{
if (skip (e))
@@ -893,15 +945,16 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& a)
{
String const& member (emember (a));
+ SemanticGraph::Complex& c (
+ dynamic_cast<SemanticGraph::Complex&> (a.scope ()));
+
String const& ns (a.definition_namespace ().name ());
- String const& dom_doc (
- edom_document (
- dynamic_cast<SemanticGraph::Complex&> (a.scope ())));
+ String const& dom_doc (edom_document (c));
os << "// " << ename (a) << endl
<< "//" << endl
@@ -982,7 +1035,7 @@ namespace CXX
{
// sequence
//
- os << "this->" << member << " .push_back (r);";
+ os << "this->" << member << ".push_back (r);";
}
else if (min (a) == 0)
{
@@ -997,6 +1050,31 @@ namespace CXX
os << "this->" << member << ".set (r);";
}
+ // Capture order.
+ //
+ if (ordered_p (c))
+ {
+ SemanticGraph::Context& ctx (c.context ());
+
+ String const& t (ctx.get<String> ("order-type"));
+ String const& m (ctx.get<String> ("order-member"));
+
+ os << "this->" << m << ".push_back (" << endl
+ << t << " (" <<
+ a.context ().get<String> ("ordered-id-name") << ", ";
+
+ if (max (a) != 1)
+ // sequence
+ //
+ os << "this->" << member << ".size () - 1";
+ else
+ // optional & one
+ //
+ os << "0";
+
+ os << "));";
+ }
+
os << "continue;";
// End of check block.
@@ -1030,7 +1108,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& a)
{
if (max (a) == 1 && min (a) == 1)
@@ -1055,7 +1133,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& a)
{
String const& member (emember (a));
@@ -1075,26 +1153,8 @@ namespace CXX
<< "{";
}
- Boolean fund (false);
- {
- IsFundamentalType traverser (fund);
- traverser.dispatch (a.type ());
- }
-
- if (fund)
- {
- os << "this->" << member << ".set (" << tr <<
- "::create (i, f, this));";
- }
- else
- {
- String type (etype (a));
-
- os << "::std::auto_ptr< " << type << " > r (" << endl
- << tr << "::create (i, f, this));"
- << endl
- << "this->" << member << ".set (r);";
- }
+ os << "this->" << member << ".set (" << tr <<
+ "::create (i, f, this));";
os << "continue;"
<< "}";
@@ -1109,7 +1169,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& a)
{
String const& member (emember (a));
@@ -1202,7 +1262,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& a)
{
String const& member (emember (a));
@@ -1238,33 +1298,31 @@ namespace CXX
Traversal::Type,
Context
{
- // If base_arg is empty then no base argument is
- // generated.
+ // If base_arg is empty then no base argument is generated.
//
- CtorBase (Context& c, String const& base_arg)
- : Context (c), base_arg_ (base_arg)
+ CtorBase (Context& c, CtorArgType at, String const& base_arg)
+ : Context (c), args_ (c, at, base_arg)
{
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Type&)
{
- if (base_arg_)
- os << base_arg_;
+ if (args_.base_arg_)
+ os << args_.base_arg_;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Enumeration&)
{
- if (base_arg_)
- os << base_arg_;
+ if (args_.base_arg_)
+ os << args_.base_arg_;
}
- Void
+ void
traverse (SemanticGraph::Complex& c)
{
- Args args (*this, base_arg_);
- args.traverse (c);
+ args_.traverse (c);
}
private:
@@ -1279,31 +1337,32 @@ namespace CXX
Traversal::Attribute,
Context
{
- Args (Context& c, String const& base_arg)
- : Context (c), base_arg_ (base_arg), first_ (true)
+ Args (Context& c, CtorArgType at, String const& base_arg)
+ : Context (c),
+ arg_type_ (at), base_arg_ (base_arg), first_ (true)
{
*this >> inherits_ >> *this;
*this >> names_ >> *this;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Type&)
{
if (base_arg_)
os << comma () << base_arg_;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Enumeration&)
{
if (base_arg_)
os << comma () << base_arg_;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Any& a)
{
- if (!options.value<CLI::generate_wildcard> ())
+ if (!options.generate_wildcard ())
return;
if (min (a) == 1 && max (a) == 1)
@@ -1314,18 +1373,43 @@ namespace CXX
}
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Element& e)
{
if (!skip (e) && min (e) == 1 && max (e) == 1)
{
// one
//
- os << comma () << ename (e);
+ bool move (false);
+
+ if (std >= cxx_version::cxx11)
+ {
+ switch (arg_type_)
+ {
+ case CtorArgType::complex_auto_ptr:
+ {
+ bool simple (true);
+ IsSimpleType t (simple);
+ t.dispatch (e.type ());
+ move = !simple;
+ break;
+ }
+ case CtorArgType::poly_auto_ptr:
+ {
+ move = polymorphic && polymorphic_p (e.type ());
+ break;
+ }
+ case CtorArgType::type:
+ break;
+ }
+ }
+
+ os << comma () << (move ? "std::move (" : "") << ename (e) <<
+ (move ? ")" : "");
}
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Attribute& a)
{
// Note that we are not including attributes with default
@@ -1345,20 +1429,23 @@ namespace CXX
String
comma ()
{
- Boolean tmp (first_);
+ bool tmp (first_);
first_ = false;
return tmp ? "" : ",\n";
}
- private:
+ public:
+ CtorArgType arg_type_;
String base_arg_;
- Boolean first_;
+
+ private:
+ bool first_;
Traversal::Inherits inherits_;
Traversal::Names names_;
};
- String base_arg_;
+ Args args_;
};
@@ -1366,12 +1453,12 @@ namespace CXX
Traversal::Attribute,
Context
{
- CtorMember (Context& c)
- : Context (c)
+ CtorMember (Context& c, CtorArgType at)
+ : Context (c), arg_type_ (at)
{
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Element& e)
{
if (skip (e))
@@ -1384,38 +1471,62 @@ namespace CXX
// sequence
//
os << "," << endl
- << " " << member << " (" << flags_type << " (), this)";
+ << " " << member << " (this)";
}
else if (min (e) == 0)
{
// optional
//
os << "," << endl
- << " " << member << " (" << flags_type << " (), this)";
+ << " " << member << " (this)";
}
else
{
// one
//
+ bool move (false);
+
+ if (std >= cxx_version::cxx11)
+ {
+ switch (arg_type_)
+ {
+ case CtorArgType::complex_auto_ptr:
+ {
+ bool simple (true);
+ IsSimpleType t (simple);
+ t.dispatch (e.type ());
+ move = !simple;
+ break;
+ }
+ case CtorArgType::poly_auto_ptr:
+ {
+ move = polymorphic && polymorphic_p (e.type ());
+ break;
+ }
+ case CtorArgType::type:
+ break;
+ }
+ }
+
os << "," << endl
- << " " << member << " (" << ename (e) << ", " <<
- flags_type << " (), this)";
+ << " " << member << " (" << (move ? "std::move (" : "") <<
+ ename (e) << (move ? ")" : "") << ", this)";
}
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Attribute& a)
{
String const& member (emember (a));
- Boolean def (a.default_p ());
+ bool def (a.default_p ());
if (min (a) == 0 && !def)
{
// optional
//
os << "," << endl
- << " " << member << " (" << flags_type << " (), this)";
+ << " " << member << " (this)";
}
else
{
@@ -1429,16 +1540,18 @@ namespace CXX
//
os << "," << endl
<< " " << member << " (" <<
- edefault_value (a) << " (), " << flags_type << " (), this)";
+ edefault_value (a) << " (), this)";
}
else
{
os << "," << endl
- << " " << member << " (" << ename (a) << ", " <<
- flags_type << " (), this)";
+ << " " << member << " (" << ename (a) << ", this)";
}
}
}
+
+ private:
+ CtorArgType arg_type_;
};
struct CtorAny: Traversal::Any,
@@ -1450,7 +1563,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Any& a)
{
String const& member (emember (a));
@@ -1482,7 +1595,7 @@ namespace CXX
}
}
- virtual Void
+ virtual void
traverse (SemanticGraph::AnyAttribute& a)
{
String const& dom_doc (
@@ -1502,7 +1615,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Member& m)
{
if (skip (m))
@@ -1528,7 +1641,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Any& a)
{
String const& member (emember (a));
@@ -1541,7 +1654,7 @@ namespace CXX
arg_name << "." << member << ", this->" << dom_doc << " ())";
}
- virtual Void
+ virtual void
traverse (SemanticGraph::AnyAttribute& a)
{
String const& member (emember (a));
@@ -1558,6 +1671,48 @@ namespace CXX
String arg_name;
};
+ struct AssignMember: Traversal::Member, Context
+ {
+ AssignMember (Context& c)
+ : Context (c)
+ {
+ }
+
+ virtual void
+ traverse (SemanticGraph::Member& m)
+ {
+ if (skip (m))
+ return;
+
+ String const& member (emember (m));
+ os << "this->" << member << " = x." << member << ";";
+ }
+ };
+
+ struct AssignAny: Traversal::Any,
+ Traversal::AnyAttribute,
+ Context
+ {
+ AssignAny (Context& c)
+ : Context (c)
+ {
+ }
+
+ virtual void
+ traverse (SemanticGraph::Any& a)
+ {
+ String const& member (emember (a));
+ os << "this->" << member << " = x." << member << ";";
+ }
+
+ virtual void
+ traverse (SemanticGraph::AnyAttribute& a)
+ {
+ String const& member (emember (a));
+ os << "this->" << member << " = x." << member << ";";
+ }
+ };
+
// Element parsing c-tor initializers.
//
@@ -1568,7 +1723,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& m)
{
if (skip (m))
@@ -1577,7 +1732,7 @@ namespace CXX
String const& member (emember (m));
os << "," << endl
- << " " << member << " (f, this)";
+ << " " << member << " (this)";
}
};
@@ -1590,7 +1745,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Any& a)
{
String const& member (emember (a));
@@ -1602,7 +1757,7 @@ namespace CXX
<< " " << member << " (this->" << dom_doc << " ())";
}
- virtual Void
+ virtual void
traverse (SemanticGraph::AnyAttribute& a)
{
String const& member (emember (a));
@@ -1627,7 +1782,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Element& e)
{
if (skip (e))
@@ -1636,10 +1791,10 @@ namespace CXX
String const& member (emember (e));
os << "," << endl
- << " " << member << " (" << flags_type << " (), this)";
+ << " " << member << " (this)";
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Attribute& a)
{
String const& member (emember (a));
@@ -1651,11 +1806,11 @@ namespace CXX
//
os << "," << endl
<< " " << member << " (" <<
- edefault_value (a) << " (), " << flags_type << " (), this)";
+ edefault_value (a) << " (), this)";
}
else
os << "," << endl
- << " " << member << " (" << flags_type << " (), this)";
+ << " " << member << " (this)";
}
};
@@ -1668,7 +1823,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Any& a)
{
String const& member (emember (a));
@@ -1680,7 +1835,7 @@ namespace CXX
<< " " << member << " (this->" << dom_doc << " ())";
}
- virtual Void
+ virtual void
traverse (SemanticGraph::AnyAttribute& a)
{
String const& member (emember (a));
@@ -1707,39 +1862,39 @@ namespace CXX
{
// generate should initially be false.
//
- HasComparisonOperator (Context& c, Boolean& generate)
+ HasComparisonOperator (Context& c, bool& generate)
: Context (c), generate_ (generate)
{
*this >> inherits_ >> *this;
*this >> names_ >> *this;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Fundamental::Type&)
{
// All built-in types are comparable.
generate_ = true;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::List&)
{
generate_ = true;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Union&)
{
generate_ = true;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Enumeration& e)
{
Traversal::Enumeration::inherits (e);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Complex& c)
{
Complex::names (c);
@@ -1748,29 +1903,29 @@ namespace CXX
Complex::inherits (c);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Member& m)
{
if (!skip (m))
generate_ = true;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Any&)
{
- if (options.value<CLI::generate_wildcard> ())
+ if (options.generate_wildcard ())
generate_ = true;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::AnyAttribute&)
{
- if (options.value<CLI::generate_wildcard> ())
+ if (options.generate_wildcard ())
generate_ = true;
}
private:
- Boolean& generate_;
+ bool& generate_;
Traversal::Inherits inherits_;
Traversal::Names names_;
@@ -1787,7 +1942,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Element& e)
{
if (skip (e))
@@ -1802,7 +1957,7 @@ namespace CXX
// dynamically-type with xsi:type.
//
SemanticGraph::Type& t (e.type ());
- Boolean poly (polymorphic && polymorphic_p (t) && !anonymous_p (t));
+ bool poly (polymorphic && polymorphic_p (t) && !anonymous_p (t));
if (!poly)
{
@@ -1812,13 +1967,11 @@ namespace CXX
}
else
{
- // aCC cannot handle an inline call to comparison_map_instance.
- //
os << "{"
<< "::xsd::cxx::tree::comparison_map< " << char_type
<< " >& cm (" << endl
- << "::xsd::cxx::tree::comparison_map_instance< 0, " <<
- char_type << " > ());"
+ << "::xsd::cxx::tree::comparison_map_instance< " <<
+ poly_plate << ", " << char_type << " > ());"
<< endl;
if (max (e) != 1)
@@ -1878,7 +2031,7 @@ namespace CXX
}
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Attribute& a)
{
String const& aname (eaname (a));
@@ -1898,7 +2051,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Any& a)
{
String const& aname (eaname (a));
@@ -1914,7 +2067,7 @@ namespace CXX
<< endl;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::AnyAttribute& a)
{
String const& aname (eaname (a));
@@ -1935,50 +2088,53 @@ namespace CXX
Traversal::AnyAttribute,
Context
{
- HasParseFunction (Context& c, Boolean& has_el, Boolean& has_at)
+ HasParseFunction (Context& c, bool& has_el, bool& has_at)
: Context (c), has_el_ (has_el), has_at_ (has_at)
{
*this >> names_ >> *this;
*this >> inherits_ >> *this;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Complex& c)
{
+ if (mixed_p (c) && !c.context ().count ("mixed-in-base"))
+ has_el_ = true;
+
names (c);
if (!(has_el_ && has_at_))
inherits (c);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Element&)
{
has_el_ = true;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Any&)
{
has_el_ = true;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Attribute&)
{
has_at_ = true;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::AnyAttribute&)
{
- if (options.value<CLI::generate_wildcard> ())
+ if (options.generate_wildcard ())
has_at_ = true;
}
private:
- Boolean& has_el_;
- Boolean& has_at_;
+ bool& has_el_;
+ bool& has_at_;
Traversal::Names names_;
Traversal::Inherits inherits_;
@@ -1993,14 +2149,14 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& c)
{
Facets f;
FacetCollector col (f);
col.traverse (c);
- for (Facets::ConstIterator i (f.begin ()); i != f.end (); ++i)
+ for (Facets::const_iterator i (f.begin ()); i != f.end (); ++i)
{
if (i->first == L"fractionDigits")
os << "{::xsd::cxx::tree::facet::fraction_digits, " <<
@@ -2012,7 +2168,7 @@ namespace CXX
}
private:
- typedef Cult::Containers::Map<String, String> Facets;
+ typedef map<String, String> Facets;
struct FacetCollector: Traversal::Complex
{
@@ -2022,7 +2178,7 @@ namespace CXX
*this >> inherits_ >> *this;
}
- virtual Void
+ virtual void
traverse (Type& c)
{
if (c.inherits_p ())
@@ -2075,21 +2231,25 @@ namespace CXX
default_ctor_any_init_ (c),
default_ctor_member_init_ (c),
ctor_any_ (c),
- ctor_member_ (c),
+ ctor_member_ (c, CtorArgType::type),
element_ctor_any_ (c),
element_ctor_member_ (c),
+ assign_any_ (c),
+ assign_member_ (c),
comparison_any_ (c),
comparison_member_ (c),
facet_array_ (c)
{
+ bool gen_wildcard (options.generate_wildcard ());
+
inherits_member_ >> member_name_;
names_element_ >> element_;
- if (options.value<CLI::generate_wildcard> ())
+ if (gen_wildcard)
names_element_ >> any_;
names_element_test_ >> element_test_;
- if (options.value<CLI::generate_wildcard> ())
+ if (gen_wildcard)
names_element_test_ >> any_test_;
names_attribute_ >> attribute_;
@@ -2097,26 +2257,32 @@ namespace CXX
names_any_attribute_ >> any_attribute_;
default_ctor_init_names_ >> default_ctor_member_init_;
- if (options.value<CLI::generate_wildcard> ())
+ if (gen_wildcard)
default_ctor_init_names_ >> default_ctor_any_init_;
ctor_names_ >> ctor_member_;
- if (options.value<CLI::generate_wildcard> ())
+ if (gen_wildcard)
ctor_names_ >> ctor_any_;
element_ctor_names_ >> element_ctor_member_;
- if (options.value<CLI::generate_wildcard> ())
+ if (gen_wildcard)
element_ctor_names_ >> element_ctor_any_;
+ assign_names_ >> assign_member_;
+ if (gen_wildcard)
+ assign_names_ >> assign_any_;
+
comparison_names_ >> comparison_member_;
- if (options.value<CLI::generate_wildcard> ())
+ if (gen_wildcard)
comparison_names_ >> comparison_any_;
}
- virtual Void
+ virtual void
traverse (Type& c)
{
+ bool gen_wildcard (options.generate_wildcard ());
+
String name (ename (c));
// If renamed name is empty then we do not need to generate
@@ -2125,7 +2291,12 @@ namespace CXX
if (renamed_type (c, name) && !name)
return;
- Boolean string_based (false);
+ SemanticGraph::Context& ctx (c.context ());
+
+ bool mixed (mixed_p (c) && !ctx.count ("mixed-in-base"));
+ bool ordered (ordered_p (c) && !ctx.count ("order-in-base"));
+
+ bool string_based (false);
{
IsStringBasedType t (string_based);
t.dispatch (c);
@@ -2137,7 +2308,7 @@ namespace CXX
t.dispatch (c);
}
- Boolean facets (false);
+ bool facets (false);
String base; // base type name
if (c.inherits_p ())
{
@@ -2200,15 +2371,15 @@ namespace CXX
// c-tors
//
- Boolean generate_no_base_ctor (false);
+ bool generate_no_base_ctor (false);
{
GenerateWithoutBaseCtor t (generate_no_base_ctor);
t.traverse (c);
}
- Boolean has_complex_non_op_args (false);
- Boolean has_poly_non_op_args (false);
- Boolean complex_poly_args_clash (true);
+ bool has_complex_non_op_args (false);
+ bool has_poly_non_op_args (false);
+ bool complex_poly_args_clash (true);
{
HasComplexPolyNonOptArgs t (*this, true,
has_complex_non_op_args,
@@ -2219,9 +2390,9 @@ namespace CXX
// default c-tor
//
- if (options.value<CLI::generate_default_ctor> ())
+ if (options.generate_default_ctor ())
{
- Boolean generate (false);
+ bool generate (false);
{
GenerateDefaultCtor t (*this, generate, generate_no_base_ctor);
t.traverse (c);
@@ -2241,6 +2412,12 @@ namespace CXX
" > ())";
}
+ if (mixed)
+ {
+ os << "," << endl
+ << " " << ctx.get<String> ("mixed-member") << " (this)";
+ }
+
names (c, default_ctor_init_names_);
os << "{";
@@ -2252,9 +2429,9 @@ namespace CXX
// c-tor (base, all-non-optional-members)
//
- if (options.value<CLI::generate_from_base_ctor> ())
+ if (options.generate_from_base_ctor ())
{
- Boolean generate (false);
+ bool generate (false);
{
GenerateFromBaseCtor t (*this, generate);
t.traverse (c);
@@ -2262,9 +2439,9 @@ namespace CXX
if (generate)
{
- Boolean has_complex_non_op_args (false);
- Boolean has_poly_non_op_args (false);
- Boolean complex_poly_args_clash (true);
+ bool has_complex_non_op_args (false);
+ bool has_poly_non_op_args (false);
+ bool complex_poly_args_clash (true);
{
HasComplexPolyNonOptArgs t (*this, false,
has_complex_non_op_args,
@@ -2281,7 +2458,7 @@ namespace CXX
inherits (c, inherits_member_);
os << "& " << base_arg;
{
- FromBaseCtorArg args (*this, FromBaseCtorArg::arg_type, true);
+ FromBaseCtorArg args (*this, CtorArgType::type, true);
Traversal::Names args_names (args);
names (c, args_names);
}
@@ -2296,6 +2473,12 @@ namespace CXX
" > ())";
}
+ if (mixed)
+ {
+ os << "," << endl
+ << " " << ctx.get<String> ("mixed-member") << " (this)";
+ }
+
names (c, ctor_names_);
os << "{";
@@ -2308,13 +2491,14 @@ namespace CXX
//
if (has_complex_non_op_args)
{
+ CtorArgType const at (CtorArgType::complex_auto_ptr);
+
os << name << "::" << endl
<< name << " (const ";
inherits (c, inherits_member_);
os << "& " << base_arg;
{
- FromBaseCtorArg args (
- *this, FromBaseCtorArg::arg_complex_auto_ptr, true);
+ FromBaseCtorArg args (*this, at, true);
Traversal::Names args_names (args);
names (c, args_names);
}
@@ -2329,7 +2513,21 @@ namespace CXX
" > ())";
}
- names (c, ctor_names_);
+ if (mixed)
+ {
+ os << "," << endl
+ << " " << ctx.get<String> ("mixed-member") << " (this)";
+ }
+
+ {
+ CtorMember t (*this, at);
+ Traversal::Names n (t);
+
+ if (gen_wildcard)
+ n >> ctor_any_;
+
+ names (c, n);
+ }
os << "{";
if (facets)
@@ -2343,13 +2541,14 @@ namespace CXX
if (polymorphic &&
has_poly_non_op_args && !complex_poly_args_clash)
{
+ CtorArgType const at (CtorArgType::poly_auto_ptr);
+
os << name << "::" << endl
<< name << " (const ";
inherits (c, inherits_member_);
os << "& " << base_arg;
{
- FromBaseCtorArg args (
- *this, FromBaseCtorArg::arg_poly_auto_ptr, true);
+ FromBaseCtorArg args (*this, at, true);
Traversal::Names args_names (args);
names (c, args_names);
}
@@ -2364,7 +2563,21 @@ namespace CXX
" > ())";
}
- names (c, ctor_names_);
+ if (mixed)
+ {
+ os << "," << endl
+ << " " << ctx.get<String> ("mixed-member") << " (this)";
+ }
+
+ {
+ CtorMember t (*this, at);
+ Traversal::Names n (t);
+
+ if (gen_wildcard)
+ n >> ctor_any_;
+
+ names (c, n);
+ }
os << "{";
if (facets)
@@ -2378,17 +2591,18 @@ namespace CXX
//
if (generate_no_base_ctor)
{
+ CtorArgType const at (CtorArgType::type);
+
os << name << "::" << endl
<< name << " (";
{
- CtorArgsWithoutBase ctor_args (
- *this, CtorArgsWithoutBase::arg_type, true, true);
+ CtorArgsWithoutBase ctor_args (*this, at, true, true);
ctor_args.dispatch (c);
}
os << ")" << endl
<< ": " << base << " (";
{
- CtorBase base (*this, "");
+ CtorBase base (*this, at, "");
Traversal::Inherits inherits_base (base);
inherits (c, inherits_base);
@@ -2403,6 +2617,12 @@ namespace CXX
" > ())";
}
+ if (mixed)
+ {
+ os << "," << endl
+ << " " << ctx.get<String> ("mixed-member") << " (this)";
+ }
+
names (c, ctor_names_);
os << "{";
@@ -2416,17 +2636,18 @@ namespace CXX
//
if (has_complex_non_op_args)
{
+ CtorArgType const at (CtorArgType::complex_auto_ptr);
+
os << name << "::" << endl
<< name << " (";
{
- CtorArgsWithoutBase ctor_args (
- *this, CtorArgsWithoutBase::arg_complex_auto_ptr, true, true);
+ CtorArgsWithoutBase ctor_args (*this, at, true, true);
ctor_args.dispatch (c);
}
os << ")" << endl
<< ": " << base << " (";
{
- CtorBase base (*this, "");
+ CtorBase base (*this, at, "");
Traversal::Inherits inherits_base (base);
inherits (c, inherits_base);
@@ -2441,7 +2662,21 @@ namespace CXX
" > ())";
}
- names (c, ctor_names_);
+ if (mixed)
+ {
+ os << "," << endl
+ << " " << ctx.get<String> ("mixed-member") << " (this)";
+ }
+
+ {
+ CtorMember t (*this, at);
+ Traversal::Names n (t);
+
+ if (gen_wildcard)
+ n >> ctor_any_;
+
+ names (c, n);
+ }
os << "{";
if (facets)
@@ -2455,17 +2690,18 @@ namespace CXX
if (polymorphic &&
has_poly_non_op_args && !complex_poly_args_clash)
{
+ CtorArgType const at (CtorArgType::poly_auto_ptr);
+
os << name << "::" << endl
<< name << " (";
{
- CtorArgsWithoutBase ctor_args (
- *this, CtorArgsWithoutBase::arg_poly_auto_ptr, true, true);
+ CtorArgsWithoutBase ctor_args (*this, at, true, true);
ctor_args.dispatch (c);
}
os << ")" << endl
<< ": " << base << " (";
{
- CtorBase base (*this, "");
+ CtorBase base (*this, at, "");
Traversal::Inherits inherits_base (base);
inherits (c, inherits_base);
@@ -2480,7 +2716,21 @@ namespace CXX
" > ())";
}
- names (c, ctor_names_);
+ if (mixed)
+ {
+ os << "," << endl
+ << " " << ctx.get<String> ("mixed-member") << " (this)";
+ }
+
+ {
+ CtorMember t (*this, at);
+ Traversal::Names n (t);
+
+ if (gen_wildcard)
+ n >> ctor_any_;
+
+ names (c, n);
+ }
os << "{";
if (facets)
@@ -2497,6 +2747,7 @@ namespace CXX
{
// c-tor (enum-value, all-non-optional-members)
//
+ CtorArgType const at (CtorArgType::type);
String base_arg (L"_xsd_" + ename (*enum_base) + L"_base");
os << name << "::" << endl
@@ -2504,8 +2755,7 @@ namespace CXX
evalue (*enum_base) << " " << base_arg;
{
- CtorArgsWithoutBase ctor_args (
- *this, CtorArgsWithoutBase::arg_type, true, false);
+ CtorArgsWithoutBase ctor_args (*this, at, true, false);
ctor_args.dispatch (c);
}
@@ -2513,7 +2763,7 @@ namespace CXX
<< ": " << base << " (";
{
- CtorBase base (*this, base_arg);
+ CtorBase base (*this, at, base_arg);
Traversal::Inherits inherits_base (base);
inherits (c, inherits_base);
@@ -2529,6 +2779,8 @@ namespace CXX
" > ())";
}
+ // Cannot be mixed.
+
names (c, ctor_names_);
os << "{";
@@ -2537,6 +2789,7 @@ namespace CXX
os << "}";
}
+ CtorArgType const at (CtorArgType::type);
String base_arg (L"_xsd_" + ename (ultimate_base (c)) + L"_base");
// c-tor (const char*, all-non-optional-members)
@@ -2545,8 +2798,7 @@ namespace CXX
<< name << " (const " << char_type << "* " << base_arg;
{
- CtorArgsWithoutBase ctor_args (
- *this, CtorArgsWithoutBase::arg_type, true, false);
+ CtorArgsWithoutBase ctor_args (*this, at, true, false);
ctor_args.dispatch (c);
}
@@ -2554,7 +2806,7 @@ namespace CXX
<< ": " << base << " (";
{
- CtorBase base (*this, base_arg);
+ CtorBase base (*this, at, base_arg);
Traversal::Inherits inherits_base (base);
inherits (c, inherits_base);
@@ -2570,6 +2822,8 @@ namespace CXX
" > ())";
}
+ // Cannot be mixed.
+
names (c, ctor_names_);
os << "{";
@@ -2584,8 +2838,7 @@ namespace CXX
<< name << " (const " << string_type << "& " << base_arg;
{
- CtorArgsWithoutBase ctor_args (
- *this, CtorArgsWithoutBase::arg_type, true, false);
+ CtorArgsWithoutBase ctor_args (*this, at, true, false);
ctor_args.dispatch (c);
}
@@ -2593,7 +2846,7 @@ namespace CXX
<< ": " << base << " (";
{
- CtorBase base (*this, base_arg);
+ CtorBase base (*this, at, base_arg);
Traversal::Inherits inherits_base (base);
inherits (c, inherits_base);
@@ -2609,6 +2862,8 @@ namespace CXX
" > ())";
}
+ // Cannot be mixed.
+
names (c, ctor_names_);
os << "{";
@@ -2619,57 +2874,66 @@ namespace CXX
// c-tor (ultimate-base, all-non-optional-members)
//
+ {
+ CtorArgType const at (CtorArgType::type);
- os << name << "::" << endl
- << name << " (";
+ os << name << "::" << endl
+ << name << " (";
- String base_arg;
+ String base_arg;
- {
- CtorArgs ctor_args (*this, CtorArgs::arg_type, base_arg);
- ctor_args.dispatch (c);
- }
+ {
+ CtorArgs ctor_args (*this, at, base_arg);
+ ctor_args.dispatch (c);
+ }
- os << ")" << endl
- << ": " << base << " (";
+ os << ")" << endl
+ << ": " << base << " (";
- {
- CtorBase base (*this, base_arg);
- Traversal::Inherits inherits_base (base);
+ {
+ CtorBase base (*this, at, base_arg);
+ Traversal::Inherits inherits_base (base);
- inherits (c, inherits_base);
- }
+ inherits (c, inherits_base);
+ }
- os << ")";
+ os << ")";
- if (edom_document_member_p (c))
- {
- os << "," << endl
- << " " << edom_document_member (c) << " (" <<
- "::xsd::cxx::xml::dom::create_document< " << char_type <<
- " > ())";
- }
+ if (edom_document_member_p (c))
+ {
+ os << "," << endl
+ << " " << edom_document_member (c) << " (" <<
+ "::xsd::cxx::xml::dom::create_document< " << char_type <<
+ " > ())";
+ }
- names (c, ctor_names_);
+ if (mixed)
+ {
+ os << "," << endl
+ << " " << ctx.get<String> ("mixed-member") << " (this)";
+ }
- os << "{";
- if (facets)
- os << "this->_facet_table (_xsd_" << name << "_facet_table);";
- os << "}";
+ names (c, ctor_names_);
+
+ os << "{";
+ if (facets)
+ os << "this->_facet_table (_xsd_" << name << "_facet_table);";
+ os << "}";
+ }
// If we have any complex arguments in the previous c-tor
// then also generate the auto_ptr version.
//
if (has_complex_non_op_args)
{
+ CtorArgType const at (CtorArgType::complex_auto_ptr);
+ String base_arg;
+
os << name << "::" << endl
<< name << " (";
- String base_arg;
-
{
- CtorArgs ctor_args (
- *this, CtorArgs::arg_complex_auto_ptr, base_arg);
+ CtorArgs ctor_args (*this, at, base_arg);
ctor_args.dispatch (c);
}
@@ -2677,7 +2941,7 @@ namespace CXX
<< ": " << base << " (";
{
- CtorBase base (*this, base_arg);
+ CtorBase base (*this, at, base_arg);
Traversal::Inherits inherits_base (base);
inherits (c, inherits_base);
@@ -2693,7 +2957,21 @@ namespace CXX
" > ())";
}
- names (c, ctor_names_);
+ if (mixed)
+ {
+ os << "," << endl
+ << " " << ctx.get<String> ("mixed-member") << " (this)";
+ }
+
+ {
+ CtorMember t (*this, at);
+ Traversal::Names n (t);
+
+ if (gen_wildcard)
+ n >> ctor_any_;
+
+ names (c, n);
+ }
os << "{";
if (facets)
@@ -2707,14 +2985,14 @@ namespace CXX
if (polymorphic &&
has_poly_non_op_args && !complex_poly_args_clash)
{
+ CtorArgType const at (CtorArgType::poly_auto_ptr);
+ String base_arg;
+
os << name << "::" << endl
<< name << " (";
- String base_arg;
-
{
- CtorArgs ctor_args (
- *this, CtorArgs::arg_poly_auto_ptr, base_arg);
+ CtorArgs ctor_args (*this, at, base_arg);
ctor_args.dispatch (c);
}
@@ -2722,7 +3000,7 @@ namespace CXX
<< ": " << base << " (";
{
- CtorBase base (*this, base_arg);
+ CtorBase base (*this, at, base_arg);
Traversal::Inherits inherits_base (base);
inherits (c, inherits_base);
@@ -2738,7 +3016,21 @@ namespace CXX
" > ())";
}
- names (c, ctor_names_);
+ if (mixed)
+ {
+ os << "," << endl
+ << " " << ctx.get<String> ("mixed-member") << " (this)";
+ }
+
+ {
+ CtorMember t (*this, at);
+ Traversal::Names n (t);
+
+ if (gen_wildcard)
+ n >> ctor_any_;
+
+ names (c, n);
+ }
os << "{";
if (facets)
@@ -2764,6 +3056,20 @@ namespace CXX
" > ())";
}
+ if (mixed)
+ {
+ String const& m (ctx.get<String> ("mixed-member"));
+ os << "," << endl
+ << " " << m << " (x." << m << ", f, this)";
+ }
+
+ if (ordered)
+ {
+ String const& m (ctx.get<String> ("order-member"));
+ os << "," << endl
+ << " " << m << " (x." << m << ")";
+ }
+
{
CopyAny copy_any (*this, "x");
CopyMember copy_member (*this, "x");
@@ -2771,7 +3077,7 @@ namespace CXX
names >> copy_member;
- if (options.value<CLI::generate_wildcard> ())
+ if (gen_wildcard)
names >> copy_any;
Complex::names (c, names);
@@ -2784,17 +3090,15 @@ namespace CXX
//
//
- Boolean he (has<Traversal::Element> (c));
- Boolean hae (has<Traversal::Any> (c));
+ bool he (has<Traversal::Element> (c));
+ bool hae (has<Traversal::Any> (c));
- Boolean ha (has<Traversal::Attribute> (c));
- Boolean haa (has<Traversal::AnyAttribute> (c));
-
- Boolean gen_wildcard (options.value<CLI::generate_wildcard> ());
+ bool ha (has<Traversal::Attribute> (c));
+ bool haa (has<Traversal::AnyAttribute> (c));
//
//
- if (!options.value<CLI::suppress_parsing> ())
+ if (!options.suppress_parsing ())
{
// c-tor (xercesc::DOMElement)
//
@@ -2804,7 +3108,7 @@ namespace CXX
<< container << "* c)" << endl
<< ": " << base << " (e, f";
- if (he || ha || hae || (haa && gen_wildcard))
+ if (he || ha || hae || (haa && gen_wildcard) || mixed)
os << " | " << flags_type << "::base";
os << ", c)";
@@ -2817,6 +3121,12 @@ namespace CXX
" > ())";
}
+ if (mixed)
+ {
+ os << "," << endl
+ << " " << ctx.get<String> ("mixed-member") << " (this)";
+ }
+
names (c, element_ctor_names_);
os << "{";
@@ -2825,12 +3135,12 @@ namespace CXX
os << "this->_facet_table (_xsd_" << name << "_facet_table);"
<< endl;
- Boolean base_has_el (false), base_has_at (false);
+ bool base_has_el (false), base_has_at (false);
// We are only interested in this information if we are
- // generating out own parse().
+ // generating our own parse().
//
- if (he || ha || hae || (haa && gen_wildcard))
+ if (he || ha || hae || (haa && gen_wildcard) || mixed)
{
if (c.inherits_p ())
{
@@ -2839,13 +3149,14 @@ namespace CXX
}
}
- //@@ throw if p is no exhausted at the end.
+ //@@ Throw if p is not exhausted at the end.
//
- if (he || ha || hae || (haa && gen_wildcard))
+ if (he || ha || hae || (haa && gen_wildcard) || mixed)
os << "if ((f & " << flags_type << "::base) == 0)"
<< "{"
<< parser_type << " p (e, " <<
- (he || hae || base_has_el ? "true, " : "false, ") <<
+ (he || hae || base_has_el || mixed_p (c) ? "true, " : "false, ") <<
+ (mixed_p (c) ? "true, " : "false, ") <<
(ha || (haa && gen_wildcard) || base_has_at ? "true" : "false")
<< ");"
<< "this->" << unclash (name, "parse") << " (p, f);"
@@ -2853,7 +3164,7 @@ namespace CXX
os << "}";
- Boolean simple (true);
+ bool simple (true);
{
IsSimpleType t (simple);
t.dispatch (c);
@@ -2891,7 +3202,7 @@ namespace CXX
os << "}";
}
- if (he || ha || hae || (haa && gen_wildcard))
+ if (he || ha || hae || (haa && gen_wildcard) || mixed)
{
os << "void " << name << "::" << endl
<< unclash (name, "parse") << " (" <<
@@ -2906,17 +3217,45 @@ namespace CXX
os << "this->" << base << "::parse (p, f);"
<< endl;
- if (he || hae)
+ if (he || hae || mixed_p (c))
{
- os << "for (; p.more_elements (); p.next_element ())"
- << "{"
- << "const " << xerces_ns << "::DOMElement& i (" <<
- "p.cur_element ());"
- << "const " << qname_type << " n (" << endl
- << "::xsd::cxx::xml::dom::name< " << char_type << " > (i));"
- << endl;
+ bool m (mixed_p (c));
+
+ os << "for (; p.more_content (); p.next_content (" <<
+ (m ? "true" : "false") << "))"
+ << "{";
- names (c, names_element_);
+ if (m)
+ {
+ String const& ma (ctx.get<String> ("mixed-aname"));
+ String const& mi (ctx.get<String> ("mixed-ordered-id-name"));
+ String const& oa (ctx.get<String> ("order-aname"));
+ String const& ot (ctx.get<String> ("order-type"));
+
+ os << "if (p.cur_is_text ())"
+ << "{"
+ << "const " << xerces_ns << "::DOMText& t (" <<
+ "p.cur_text ());"
+ << "this->" << ma << " ().push_back (" << endl
+ << "::xsd::cxx::xml::transcode< " << char_type << " > (" <<
+ "t.getData (), t.getLength ()));"
+ << "this->" << oa << " ().push_back (" << endl
+ << ot << " (" << mi << "," << endl
+ << "this->" << ma << " ().size () - 1));"
+ << "continue;"
+ << "}";
+ }
+
+ if (he || hae)
+ {
+ os << "const " << xerces_ns << "::DOMElement& i (" <<
+ "p.cur_element ());"
+ << "const " << qname_type << " n (" << endl
+ << "::xsd::cxx::xml::dom::name< " << char_type << " > (i));"
+ << endl;
+
+ names (c, names_element_);
+ }
os << "break;"
<< "}";
@@ -2977,6 +3316,45 @@ namespace CXX
<< "return new class " << name << " (*this, f, c);"
<< "}";
+ // operator=
+ //
+ if (!options.suppress_assignment () &&
+ (he || ha || (gen_wildcard && (hae || haa))))
+ {
+ os << name << "& " << name << "::" << endl
+ << "operator= (const " << name << "& x)"
+ << "{"
+ << "if (this != &x)"
+ << "{"
+ << "static_cast< " << base << "& > (*this) = x;";
+
+ // Note that here we don't assign the DOMDocument that is
+ // used to hold wildcard fragments. Each document has its
+ // own copy.
+
+ // Mixed text content.
+ //
+ if (mixed)
+ {
+ String const& m (ctx.get<String> ("mixed-member"));
+ os << "this->" << m << " = x." << m << ";";
+ }
+
+ // Order container.
+ //
+ if (ordered)
+ {
+ String const& m (ctx.get<String> ("order-member"));
+ os << "this->" << m << " = x." << m << ";";
+ }
+
+ names (c, assign_names_);
+
+ os << "}"
+ << "return *this;"
+ << "}";
+ }
+
// d-tor
//
os << name << "::" << endl
@@ -2986,36 +3364,44 @@ namespace CXX
// Register with type factory map.
//
- if (polymorphic && polymorphic_p (c) && !anonymous_p (c))
+ if (polymorphic && polymorphic_p (c))
{
// Note that we are using the original type name.
//
String const& name (ename (c));
- if (!options.value<CLI::suppress_parsing> ())
+ // If this type is anonymous but substitutes, then it will
+ // be registered as part of the substitution registration.
+ //
+ if (!anonymous_p (c) && !options.suppress_parsing ())
+ {
os << "static" << endl
- << "const ::xsd::cxx::tree::type_factory_initializer< 0, " <<
- char_type << ", " << name << " >" << endl
+ << "const ::xsd::cxx::tree::type_factory_initializer< " <<
+ poly_plate << ", " << char_type << ", " << name << " >" << endl
<< "_xsd_" << name << "_type_factory_init (" << endl
<< strlit (c.name ()) << "," << endl
<< strlit (xml_ns_name (c)) << ");"
<< endl;
+ }
- if (options.value<CLI::generate_comparison> ())
+ if ((!anonymous_p (c) || anonymous_substitutes_p (c)) &&
+ options.generate_comparison ())
+ {
os << "static" << endl
- << "const ::xsd::cxx::tree::comparison_initializer< 0, " <<
- char_type << ", " << name << " >" << endl
+ << "const ::xsd::cxx::tree::comparison_initializer< " <<
+ poly_plate << ", " << char_type << ", " << name << " >" << endl
<< "_xsd_" << name << "_comparison_init;"
<< endl;
+ }
}
// Comparison operators.
//
- if (options.value<CLI::generate_comparison> () &&
- (he || ha || !c.inherits_p () ||
+ if (options.generate_comparison () &&
+ (he || ha || mixed || ordered || !c.inherits_p () ||
((hae || haa) && gen_wildcard)))
{
- Boolean base_comp (false);
+ bool base_comp (false);
if (c.inherits_p ())
{
@@ -3023,8 +3409,8 @@ namespace CXX
test.dispatch (c.inherits ().base ());
}
- Boolean has_body (he || ha || base_comp ||
- ((hae || haa) && gen_wildcard));
+ bool has_body (he || ha || ordered || mixed || base_comp ||
+ ((hae || haa) && gen_wildcard));
os << "bool" << endl
<< "operator== (const " << name << "&" <<
@@ -3042,6 +3428,22 @@ namespace CXX
Complex::names (c, comparison_names_);
}
+ if (mixed)
+ {
+ String const& an (ctx.get<String> ("mixed-aname"));
+ os << "if (!(x." << an << " () == y." << an << " ()))" << endl
+ << "return false;"
+ << endl;
+ }
+
+ if (ordered)
+ {
+ String const& an (ctx.get<String> ("order-aname"));
+ os << "if (!(x." << an << " () == y." << an << " ()))" << endl
+ << "return false;"
+ << endl;
+ }
+
os << "return true;"
<< "}";
@@ -3088,6 +3490,10 @@ namespace CXX
ElementCtorMember element_ctor_member_;
Traversal::Names element_ctor_names_;
+ AssignAny assign_any_;
+ AssignMember assign_member_;
+ Traversal::Names assign_names_;
+
AnyComparison comparison_any_;
MemberComparison comparison_member_;
Traversal::Names comparison_names_;
@@ -3105,27 +3511,27 @@ namespace CXX
GlobalElement (Context& c)
: GlobalElementBase (c),
Context (c),
- element_type_ (c.options.value<CLI::generate_element_type> ()),
- element_map_ (c.options.value<CLI::generate_element_map> ()),
+ element_type_ (c.options.generate_element_type ()),
+ element_map_ (c.options.generate_element_map ()),
type_name_ (c)
{
belongs_ >> type_name_;
}
- virtual Void
+ virtual void
traverse (Type& e)
{
if (element_type_ && doc_root_p (e))
{
SemanticGraph::Type& t (e.type ());
- Boolean fund (false);
+ bool fund (false);
{
IsFundamentalType test (fund);
test.dispatch (t);
}
- Boolean simple (true);
+ bool simple (true);
if (!fund)
{
IsSimpleType test (simple);
@@ -3166,11 +3572,11 @@ namespace CXX
// default c-tor
//
- if (options.value<CLI::generate_default_ctor> ())
+ if (options.generate_default_ctor ())
{
os << name << "::" << endl
<< name << " ()" << endl
- << ": " << member << " (0, 0)"
+ << ": " << member << " (0)"
<< "{"
<< "}";
}
@@ -3179,7 +3585,7 @@ namespace CXX
//
os << name << "::" << endl
<< name << " (const " << type << "& x)" << endl
- << ": " << member << " (x, 0, 0)"
+ << ": " << member << " (x, 0)"
<< "{"
<< "}";
@@ -3189,8 +3595,8 @@ namespace CXX
if (!simple || (polymorphic && polymorphic_p (t)))
{
os << name << "::" << endl
- << name << " (::std::auto_ptr< " << type << " > p)" << endl
- << ": " << member << " (p, 0, 0)"
+ << name << " (" << auto_ptr << "< " << type << " > p)" << endl
+ << ": " << member << " (p, 0)"
<< "{"
<< "}";
}
@@ -3201,7 +3607,7 @@ namespace CXX
String const& name_member (ec.get<String> ("element-name-member"));
String const& ns_member (ec.get<String> ("element-ns-member"));
- Boolean parsing (!options.value<CLI::suppress_parsing> ());
+ bool parsing (!options.suppress_parsing ());
if (parsing)
{
String const& tr (etraits (e));
@@ -3209,7 +3615,7 @@ namespace CXX
os << name << "::" << endl
<< name << " (const " << xerces_ns << "::DOMElement& e, " <<
flags_type << " f)" << endl
- << ": " << member << " (f, 0)"
+ << ": " << member << " (0)"
<< "{"
<< "const " << qname_type << " n (" << endl
<< "::xsd::cxx::xml::dom::name< " << char_type << " > (e));"
@@ -3302,14 +3708,14 @@ namespace CXX
}
if (polymorphic && e.substitutes_p () &&
- !options.value<CLI::suppress_parsing> ())
+ !options.suppress_parsing ())
{
String const& name (ename (e));
Type& r (e.substitutes ().root ());
os << "static" << endl
- << "const ::xsd::cxx::tree::element_factory_initializer< 0, " <<
- char_type << ", ";
+ << "const ::xsd::cxx::tree::element_factory_initializer< " <<
+ poly_plate << ", " << char_type << ", ";
belongs (e, belongs_);
@@ -3325,32 +3731,30 @@ namespace CXX
}
private:
- Boolean element_type_;
- Boolean element_map_;
+ bool element_type_;
+ bool element_map_;
Traversal::Belongs belongs_;
MemberTypeName type_name_;
};
}
- Void
- generate_tree_source (Context& ctx,
- UnsignedLong first,
- UnsignedLong last)
+ void
+ generate_tree_source (Context& ctx, size_t first, size_t last)
{
- if (ctx.options.value<CLI::generate_wildcard> ())
+ if (ctx.options.generate_wildcard ())
{
ctx.os << "#include <xsd/cxx/xml/dom/wildcard-source.hxx>" << endl
<< endl;
}
- if (!ctx.options.value<CLI::suppress_parsing> ())
+ if (!ctx.options.suppress_parsing ())
ctx.os << "#include <xsd/cxx/xml/dom/parsing-source.hxx>" << endl
<< endl;
if (ctx.polymorphic)
{
- Boolean parsing (!ctx.options.value<CLI::suppress_parsing> ());
- Boolean comparison (ctx.options.value<CLI::generate_comparison> ());
+ bool parsing (!ctx.options.suppress_parsing ());
+ bool comparison (ctx.options.generate_comparison ());
if (parsing)
ctx.os << "#include <xsd/cxx/tree/type-factory-map.hxx>" << endl
@@ -3362,8 +3766,8 @@ namespace CXX
if (parsing || comparison)
{
- Boolean import_maps (ctx.options.value<CLI::import_maps> ());
- Boolean export_maps (ctx.options.value<CLI::export_maps> ());
+ bool import_maps (ctx.options.import_maps ());
+ bool export_maps (ctx.options.export_maps ());
if (import_maps || export_maps)
{
@@ -3379,39 +3783,47 @@ namespace CXX
if (parsing && export_maps)
ctx.os << "template struct __declspec (dllexport) " <<
- "type_factory_plate< 0, " << ctx.char_type << " >;";
+ "type_factory_plate< " << ctx.poly_plate << ", " <<
+ ctx.char_type << " >;";
if (parsing && import_maps)
ctx.os << "template struct __declspec (dllimport) " <<
- "type_factory_plate< 0, " << ctx.char_type << " >;";
+ "type_factory_plate< " << ctx.poly_plate << ", " <<
+ ctx.char_type << " >;";
if (comparison && export_maps)
ctx.os << "template struct __declspec (dllexport) " <<
- "comparison_plate< 0, " << ctx.char_type << " >;";
+ "comparison_plate< " << ctx.poly_plate << ", " <<
+ ctx.char_type << " >;";
if (comparison && import_maps)
ctx.os << "template struct __declspec (dllimport) " <<
- "comparison_plate< 0, " << ctx.char_type << " >;";
+ "comparison_plate< " << ctx.poly_plate << ", " <<
+ ctx.char_type << " >;";
ctx.os << "#elif defined(__GNUC__) && __GNUC__ >= 4" << endl;
if (parsing)
ctx.os << "template struct __attribute__ ((visibility(\"default\"))) " <<
- "type_factory_plate< 0, " << ctx.char_type << " >;";
+ "type_factory_plate< " << ctx.poly_plate << ", " <<
+ ctx.char_type << " >;";
if (comparison)
ctx.os << "template struct __attribute__ ((visibility(\"default\"))) " <<
- "comparison_plate< 0, " << ctx.char_type << " >;";
+ "comparison_plate< " << ctx.poly_plate << ", " <<
+ ctx.char_type << " >;";
ctx.os << "#elif defined(XSD_MAP_VISIBILITY)" << endl;
if (parsing)
ctx.os << "template struct XSD_MAP_VISIBILITY " <<
- "type_factory_plate< 0, " << ctx.char_type << " >;";
+ "type_factory_plate< " << ctx.poly_plate << ", " <<
+ ctx.char_type << " >;";
if (comparison)
ctx.os << "template struct XSD_MAP_VISIBILITY " <<
- "comparison_plate< 0, " << ctx.char_type << " >;";
+ "comparison_plate< " << ctx.poly_plate << ", " <<
+ ctx.char_type << " >;";
ctx.os << "#endif" << endl
<< "}" // tree
@@ -3426,15 +3838,15 @@ namespace CXX
if (parsing)
ctx.os << "static" << endl
- << "const ::xsd::cxx::tree::type_factory_plate< 0, " <<
- ctx.char_type << " >" << endl
+ << "const ::xsd::cxx::tree::type_factory_plate< " <<
+ ctx.poly_plate << ", " << ctx.char_type << " >" << endl
<< "type_factory_plate_init;"
<< endl;
if (comparison)
ctx.os << "static" << endl
- << "const ::xsd::cxx::tree::comparison_plate< 0, " <<
- ctx.char_type << " >" << endl
+ << "const ::xsd::cxx::tree::comparison_plate< " <<
+ ctx.poly_plate << ", " << ctx.char_type << " >" << endl
<< "comparison_plate_init;"
<< endl;
@@ -3443,7 +3855,7 @@ namespace CXX
}
Traversal::Schema schema;
- Traversal::Sources sources;
+ Sources sources;
Traversal::Names names_ns, names;
Namespace ns (ctx, first, last);
diff --git a/xsd/xsd/cxx/tree/tree-source.hxx b/xsd/xsd/cxx/tree/tree-source.hxx
index a1b4778..b2d96f7 100644
--- a/xsd/xsd/cxx/tree/tree-source.hxx
+++ b/xsd/xsd/cxx/tree/tree-source.hxx
@@ -1,6 +1,5 @@
// file : xsd/cxx/tree/tree-source.hxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#ifndef CXX_TREE_TREE_SOURCE_HXX
@@ -12,8 +11,8 @@ namespace CXX
{
namespace Tree
{
- Void
- generate_tree_source (Context&, UnsignedLong first, UnsignedLong last);
+ void
+ generate_tree_source (Context&, size_t first, size_t last);
}
}
diff --git a/xsd/xsd/cxx/tree/validator.cxx b/xsd/xsd/cxx/tree/validator.cxx
index 88451ba..ce3dcd8 100644
--- a/xsd/xsd/cxx/tree/validator.cxx
+++ b/xsd/xsd/cxx/tree/validator.cxx
@@ -1,20 +1,18 @@
// file : xsd/cxx/tree/validator.cxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
-#include <cxx/tree/validator.hxx>
+#include <set>
+#include <iostream>
-#include <cult/containers/set.hxx>
+#include <cxx/tree/validator.hxx>
#include <xsd-frontend/semantic-graph.hxx>
#include <xsd-frontend/traversal.hxx>
#include <cxx/tree/elements.hxx>
-#include <iostream>
-
-using std::wcerr;
+using namespace std;
namespace CXX
{
@@ -27,15 +25,15 @@ namespace CXX
public:
ValidationContext (SemanticGraph::Schema& root,
SemanticGraph::Path const& path,
- CLI::Options const& options,
+ Tree::options const& ops,
const WarningSet& disabled_warnings,
Counts const& counts,
- Boolean generate_xml_schema,
- Boolean& valid_)
+ bool generate_xml_schema,
+ bool& valid_)
: Context (std::wcerr,
root,
path,
- options,
+ ops,
counts,
generate_xml_schema,
0,
@@ -53,8 +51,8 @@ namespace CXX
}
public:
- Boolean
- is_disabled (Char const* w)
+ bool
+ is_disabled (char const* w)
{
return disabled_warnings_all_ ||
disabled_warnings_.find (w) != disabled_warnings_.end ();
@@ -95,12 +93,12 @@ namespace CXX
protected:
const WarningSet& disabled_warnings_;
- Boolean disabled_warnings_all_;
+ bool disabled_warnings_all_;
- Boolean& valid;
+ bool& valid;
- Boolean& subst_group_warning_issued;
- Boolean subst_group_warning_issued_;
+ bool& subst_group_warning_issued;
+ bool subst_group_warning_issued_;
};
@@ -122,7 +120,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Element& e)
{
if (skip (e))
@@ -130,13 +128,13 @@ namespace CXX
using SemanticGraph::Any;
- Boolean q (e.qualified_p ());
+ bool q (e.qualified_p ());
String ns (q ? e.namespace_ ().name () : "");
for (Any::NamespaceIterator i (any_.namespace_begin ());
i != any_.namespace_end (); ++i)
{
- Boolean failed (false);
+ bool failed (false);
if (*i == L"##any")
{
@@ -205,14 +203,14 @@ namespace CXX
{
}
- virtual Void
+ virtual void
post (Type& c)
{
// Go down the inheritance hierarchy.
//
if (down_)
{
- Boolean up = up_;
+ bool up = up_;
up_ = false;
if (c.inherits_p ())
@@ -225,7 +223,7 @@ namespace CXX
//
if (up_)
{
- Boolean down = down_;
+ bool down = down_;
down_ = false;
for (Type::BegetsIterator i (c.begets_begin ());
@@ -239,10 +237,10 @@ namespace CXX
}
private:
- Boolean up_, down_;
+ bool up_, down_;
};
- virtual Void
+ virtual void
traverse (SemanticGraph::Any& a)
{
using SemanticGraph::Compositor;
@@ -295,7 +293,7 @@ namespace CXX
}
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Complex& c)
{
using SemanticGraph::Schema;
@@ -341,7 +339,7 @@ namespace CXX
Complex::traverse (c);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Type& t)
{
// This is also used to traverse Complex.
@@ -352,7 +350,7 @@ namespace CXX
}
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Element& e)
{
if (is_disabled ("T002"))
@@ -379,7 +377,7 @@ namespace CXX
// Return true if root sources s.
//
- Boolean
+ bool
sources_p (SemanticGraph::Schema& root, SemanticGraph::Schema& s)
{
using SemanticGraph::Schema;
@@ -399,9 +397,9 @@ namespace CXX
}
private:
- Containers::Set<String> types_;
+ set<String> types_;
- Traversal::Sources sources_;
+ Sources sources_;
Traversal::Names schema_names_;
Traversal::Namespace ns_;
@@ -432,7 +430,7 @@ namespace CXX
*this >> names_;
}
- Boolean
+ bool
traverse_common (SemanticGraph::Member& m)
{
SemanticGraph::Type& t (m.type ());
@@ -461,7 +459,7 @@ namespace CXX
<< "automatically name them"
<< endl;
- if (!options.value<CLI::show_anonymous> ())
+ if (!options.show_anonymous ())
wcerr << t.file ()
<< ": info: use --show-anonymous option to see these "
<< "types" << endl;
@@ -473,14 +471,14 @@ namespace CXX
return false;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Element& e)
{
if (skip (e)) return;
if (traverse_common (e))
{
- if (options.value<CLI::show_anonymous> ())
+ if (options.show_anonymous ())
{
wcerr << e.file () << ":" << e.line () << ":" << e.column ()
<< ": error: element '" << xpath (e) << "' "
@@ -491,12 +489,12 @@ namespace CXX
Traversal::Element::traverse (e);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Attribute& a)
{
if (traverse_common (a))
{
- if (options.value<CLI::show_anonymous> ())
+ if (options.show_anonymous ())
{
wcerr << a.file () << ":" << a.line () << ":" << a.column ()
<< ": error: attribute '" << xpath (a) << "' "
@@ -508,11 +506,11 @@ namespace CXX
}
private:
- Boolean anonymous_error_issued_;
+ bool anonymous_error_issued_;
- Containers::Set<String> types_;
+ set<String> types_;
- Traversal::Sources sources_;
+ Sources sources_;
Traversal::Names schema_names_;
Traversal::Namespace ns_;
@@ -521,27 +519,21 @@ namespace CXX
};
}
- Validator::
- Validator ()
- {
- // Dummy ctor, helps with long symbols on HP-UX.
- }
-
- Boolean Validator::
- validate (CLI::Options const& options,
+ bool Validator::
+ validate (options const& ops,
SemanticGraph::Schema& schema,
SemanticGraph::Path const& path,
const WarningSet& disabled_warnings,
Counts const& counts)
{
- Boolean valid (true);
+ bool valid (true);
ValidationContext ctx (
- schema, path, options, disabled_warnings, counts, false, valid);
+ schema, path, ops, disabled_warnings, counts, false, valid);
//
//
- Boolean import_maps (options.value<CLI::import_maps> ());
- Boolean export_maps (options.value<CLI::export_maps> ());
+ bool import_maps (ops.import_maps ());
+ bool export_maps (ops.export_maps ());
if (import_maps && export_maps)
{
@@ -569,17 +561,17 @@ namespace CXX
//
//
- if (options.value<CLI::char_type> () != "char" &&
- options.value<CLI::char_type> () != "wchar_t" &&
+ if (ops.char_type () != "char" &&
+ ops.char_type () != "wchar_t" &&
!ctx.is_disabled ("T003"))
{
wcerr << "warning T003: unknown base character type '" <<
- options.value<CLI::char_type> ().c_str () << "'" << endl;
+ ops.char_type ().c_str () << "'" << endl;
}
//
//
- NarrowString tn (options.value<CLI::type_naming> ());
+ NarrowString tn (ops.type_naming ());
if (tn != "knr" && tn != "ucc" && tn != "java")
{
@@ -589,7 +581,7 @@ namespace CXX
return false;
}
- NarrowString fn (options.value<CLI::function_naming> ());
+ NarrowString fn (ops.function_naming ());
if (fn != "knr" && fn != "lcc" && fn != "java")
{
@@ -601,11 +593,11 @@ namespace CXX
//
//
- Boolean element_type (options.value<CLI::generate_element_type> ());
- Boolean par (!options.value<CLI::suppress_parsing> ());
- Boolean ser (options.value<CLI::generate_serialization> ());
+ bool element_type (ops.generate_element_type ());
+ bool par (!ops.suppress_parsing ());
+ bool ser (ops.generate_serialization ());
- if (options.value<CLI::generate_element_map> ())
+ if (ops.generate_element_map ())
{
if (!element_type)
{
@@ -631,11 +623,11 @@ namespace CXX
if (counts.global_elements > 1 &&
(element_type || par || ser) &&
- !options.value<CLI::root_element_first> () &&
- !options.value<CLI::root_element_last> () &&
- !options.value<CLI::root_element_all> () &&
- !options.value<CLI::root_element_none> () &&
- options.value<CLI::root_element> ().empty () &&
+ !ops.root_element_first () &&
+ !ops.root_element_last () &&
+ !ops.root_element_all () &&
+ !ops.root_element_none () &&
+ ops.root_element ().empty () &&
!ctx.is_disabled ("T004"))
{
wcerr << schema.file () << ": warning T004: generating ";
diff --git a/xsd/xsd/cxx/tree/validator.hxx b/xsd/xsd/cxx/tree/validator.hxx
index da0c441..58ec85e 100644
--- a/xsd/xsd/cxx/tree/validator.hxx
+++ b/xsd/xsd/cxx/tree/validator.hxx
@@ -1,13 +1,12 @@
// file : xsd/cxx/tree/validator.hxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#ifndef CXX_TREE_VALIDATOR_HXX
#define CXX_TREE_VALIDATOR_HXX
#include <cxx/tree/elements.hxx>
-#include <cxx/tree/cli.hxx>
+#include <cxx/tree/options.hxx>
#include <xsd.hxx>
@@ -18,10 +17,8 @@ namespace CXX
class Validator
{
public:
- Validator (); // Dummy ctor, helps with long symbols on HP-UX.
-
- Boolean
- validate (CLI::Options const& options,
+ bool
+ validate (options const&,
SemanticGraph::Schema&,
SemanticGraph::Path const& tu,
const WarningSet& disabled_warnings,
diff --git a/xsd/xsd/elements.hxx b/xsd/xsd/elements.hxx
index 3a535a6..b09803f 100644
--- a/xsd/xsd/elements.hxx
+++ b/xsd/xsd/elements.hxx
@@ -1,37 +1,30 @@
// file : xsd/elements.hxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2006-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2006-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#ifndef ELEMENTS_HXX
#define ELEMENTS_HXX
-#include <cult/types.hxx>
-
#include <xsd-frontend/semantic-graph.hxx>
#include <xsd-frontend/traversal.hxx>
-using namespace Cult;
-typedef WideString String;
+#include <types.hxx>
namespace SemanticGraph = XSDFrontend::SemanticGraph;
namespace Traversal = XSDFrontend::Traversal;
-
// Anonymous feedback via belongs edge.
//
-struct AnonymousBase : Traversal::Element,
- Traversal::Attribute
+struct AnonymousBase : Traversal::Element, Traversal::Attribute
{
- AnonymousBase (Traversal::NodeDispatcherBase& d1)
+ AnonymousBase (Traversal::NodeDispatcher& d1)
: complex_ (&d1, 0)
{
edge_traverser (belongs_);
belongs_.node_traverser (complex_);
}
- AnonymousBase (Traversal::NodeDispatcherBase& d1,
- Traversal::NodeDispatcherBase& d2)
+ AnonymousBase (Traversal::NodeDispatcher& d1, Traversal::NodeDispatcher& d2)
: complex_ (&d1, &d2)
{
edge_traverser (belongs_);
@@ -65,7 +58,7 @@ public:
public:
- virtual Void
+ virtual void
traverse (SemanticGraph::Element& e)
{
SemanticGraph::Type& t (e.type ());
@@ -84,7 +77,7 @@ public:
}
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Attribute& a)
{
SemanticGraph::Type& t (a.type ());
@@ -106,13 +99,12 @@ public:
private:
struct Complex : Traversal::Complex
{
- Complex (Traversal::NodeDispatcherBase* d1,
- Traversal::NodeDispatcherBase* d2)
+ Complex (Traversal::NodeDispatcher* d1, Traversal::NodeDispatcher* d2)
: d1_ (d1), d2_ (d2)
{
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Complex& c)
{
if (d1_)
@@ -123,8 +115,8 @@ private:
}
private:
- Traversal::NodeDispatcherBase* d1_;
- Traversal::NodeDispatcherBase* d2_;
+ Traversal::NodeDispatcher* d1_;
+ Traversal::NodeDispatcher* d2_;
} complex_;
diff --git a/xsd/xsd/makefile b/xsd/xsd/makefile
index cc04568..d57022d 100644
--- a/xsd/xsd/makefile
+++ b/xsd/xsd/makefile
@@ -1,6 +1,5 @@
# file : xsd/makefile
-# author : Boris Kolpackov <boris@codesynthesis.com>
-# copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+# copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
# license : GNU GPL v2 + exceptions; see accompanying LICENSE file
include $(dir $(lastword $(MAKEFILE_LIST)))../build/bootstrap.make
@@ -8,7 +7,8 @@ include $(dir $(lastword $(MAKEFILE_LIST)))../build/bootstrap.make
cxx_tun := xsd.cxx
cxx_tun += cxx/elements.cxx \
- cxx/literal-map.cxx
+ cxx/literal-map.cxx \
+ cxx/option-types.cxx
cxx_tun += cxx/parser/elements.cxx \
cxx/parser/validator.cxx \
@@ -31,6 +31,7 @@ cxx_tun += cxx/tree/elements.cxx \
cxx/tree/validator.cxx \
cxx/tree/counter.cxx \
cxx/tree/name-processor.cxx \
+ cxx/tree/order-processor.cxx \
cxx/tree/polymorphism-processor.cxx \
cxx/tree/default-value.cxx \
cxx/tree/generator.cxx \
@@ -49,18 +50,24 @@ cxx_tun += cxx/tree/elements.cxx \
cxx/tree/stream-extraction-source.cxx
-# Type map
+# Type map.
#
cxx_tun += type-map/lexer.cxx \
type-map/parser.cxx
-# Processing
+# Processing.
#
cxx_tun += processing/cardinality/processor.cxx \
processing/inheritance/processor.cxx
+# Options file.
+#
+cli_tun := options.cli \
+ cxx/options.cli \
+ cxx/tree/options.cli \
+ cxx/parser/options.cli
-cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o))
+cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o) $(cli_tun:.cli=.o))
cxx_od := $(cxx_obj:.o=.o.d)
xsd := $(out_base)/xsd
@@ -72,20 +79,12 @@ clean := $(out_base)/.clean
# Import.
#
$(call import,\
- $(scf_root)/import/libcult/stub.make,\
- l: cult.l,cpp-options: cult.l.cpp-options)
-
-$(call import,\
- $(scf_root)/import/libbackend-elements/stub.make,\
- l: be.l,cpp-options: be.l.cpp-options)
-
-$(call import,\
- $(scf_root)/import/libboost/regex/stub.make,\
- l: re.l,cpp-options: re.l.cpp-options)
+ $(scf_root)/import/cli/stub.make,\
+ cli: cli,cli-rules: cli_rules)
$(call import,\
- $(scf_root)/import/libboost/filesystem/stub.make,\
- l: fs.l,cpp-options: fs.l.cpp-options)
+ $(scf_root)/import/libcutl/stub.make,\
+ l: cutl.l,cpp-options: cutl.l.cpp-options)
$(call import,\
$(scf_root)/import/libxsd-frontend/stub.make,\
@@ -97,18 +96,52 @@ $(call import,\
# Build.
#
-$(xsd): $(cxx_obj) $(xsd_fe.l) $(be.l) $(cult.l) $(fs.l) $(re.l) $(xerces_c.l)
+$(xsd): $(cxx_obj) $(xsd_fe.l) $(cutl.l) $(xerces_c.l)
-$(cxx_obj) $(cxx_od): cpp_options := -I$(src_base)
+$(cxx_obj) $(cxx_od): cpp_options := -I$(out_base) -I$(src_base)
$(cxx_obj) $(cxx_od): \
$(xsd_fe.l.cpp-options) \
- $(be.l.cpp-options) \
- $(cult.l.cpp-options) \
- $(fs.l.cpp-options) \
- $(re.l.cpp-options) \
+ $(cutl.l.cpp-options) \
$(xerces_c.l.cpp-options)
-$(call include-dep,$(cxx_od))
+genf := $(cli_tun:.cli=.hxx) $(cli_tun:.cli=.ixx) $(cli_tun:.cli=.cxx)
+gen := $(addprefix $(out_base)/,$(genf))
+
+# Don't depend on installed executable since it may not exist.
+#
+ifneq ($(cli),cli)
+$(gen): $(cli)
+endif
+$(gen): cli := $(cli)
+$(gen): cli_options += \
+-I $(src_base) \
+--generate-specifier \
+--ostream-type ::std::wostream \
+--exclude-base \
+--suppress-undocumented \
+--generate-file-scanner \
+--include-with-brackets \
+--option-length 28 \
+--cxx-prologue '\#include <options-parser.hxx>'
+
+#--include-prefix xsd
+#--guard-prefix XSD
+
+$(addprefix $(out_base)/cxx/options,.hxx .ixx .cxx): $(src_base)/options.cli
+$(addprefix $(out_base)/cxx/options,.hxx .ixx .cxx): cli_options += \
+--include-prefix cxx --guard-prefix CXX
+
+$(addprefix $(out_base)/cxx/tree/options,.hxx .ixx .cxx): \
+$(src_base)/options.cli $(src_base)/cxx/options.cli
+$(addprefix $(out_base)/cxx/tree/options,.hxx .ixx .cxx): cli_options += \
+--include-prefix cxx/tree --guard-prefix CXX_TREE
+
+$(addprefix $(out_base)/cxx/parser/options,.hxx .ixx .cxx): \
+$(src_base)/options.cli $(src_base)/cxx/options.cli
+$(addprefix $(out_base)/cxx/parser/options,.hxx .ixx .cxx): cli_options += \
+--include-prefix cxx/parser --guard-prefix CXX_PARSER
+
+$(call include-dep,$(cxx_od),$(cxx_obj),$(gen))
# Alias for default target.
#
@@ -134,12 +167,16 @@ $(clean): \
$(addsuffix .cxx.clean,$(cxx_obj)) \
$(addsuffix .cxx.clean,$(cxx_od))
+ifneq ($(xsd_clean_gen),n)
+$(clean): $(addprefix $(out_base)/,$(cli_tun:.cli=.cxx.cli.clean))
+endif
+
# Generated .gitignore.
#
ifeq ($(out_base),$(src_base))
$(xsd): | $(out_base)/.gitignore
-$(out_base)/.gitignore: files := xsd
+$(out_base)/.gitignore: files := xsd $(genf)
$(clean): $(out_base)/.gitignore.clean
$(call include,$(bld_root)/git/gitignore.make)
@@ -147,6 +184,7 @@ endif
# How to.
#
+$(call include,$(cli_rules))
$(call include,$(bld_root)/cxx/o-e.make)
$(call include,$(bld_root)/cxx/cxx-o.make)
$(call include,$(bld_root)/cxx/cxx-d.make)
diff --git a/xsd/xsd/options-parser.hxx b/xsd/xsd/options-parser.hxx
new file mode 100644
index 0000000..0f370cd
--- /dev/null
+++ b/xsd/xsd/options-parser.hxx
@@ -0,0 +1,30 @@
+// file : xsd/options-parser.hxx
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#ifndef OPTIONS_PARSER_HXX
+#define OPTIONS_PARSER_HXX
+
+#include <types.hxx>
+#include <options.hxx>
+
+namespace cli
+{
+ template <>
+ struct parser<NarrowString>
+ {
+ static void
+ parse (NarrowString& x, bool& xs, scanner& s)
+ {
+ xs = true;
+ const char* o (s.next ());
+
+ if (s.more ())
+ x = s.next ();
+ else
+ throw missing_value (o);
+ }
+ };
+}
+
+#endif // OPTIONS_PARSER_HXX
diff --git a/xsd/xsd/options.cli b/xsd/xsd/options.cli
new file mode 100644
index 0000000..1ebb38e
--- /dev/null
+++ b/xsd/xsd/options.cli
@@ -0,0 +1,313 @@
+// file : xsd/options.cli
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+include <cstddef>; // std::size_t
+
+include <types.hxx>; // NarrowString, NarrowStrings
+
+class help_options
+{
+ // These are all documented elsewhere.
+ //
+ bool --help;
+ bool --version;
+ bool --proprietary-license;
+};
+
+class options = 0
+{
+ NarrowStrings --disable-warning
+ {
+ "<warn>",
+ "Disable printing warning with id <warn>. If \cb{all} is specified for
+ the warning id then all warnings are disabled."
+ };
+
+ // The following option is "fake" in that it is actually handled by
+ // argv_file_scanner. We have it here to get the documentation.
+ //
+ std::string --options-file
+ {
+ "<file>",
+ "Read additional options from <file>. Each option should appearing on a
+ separate line optionally followed by space and an option value. Empty
+ lines and lines starting with \cb{#} are ignored. Option values can
+ be enclosed in double (\cb{\"}) or single (\cb{'}) quotes to preserve
+ leading and trailing whitespaces as well as to specify empty values.
+ If the value itself contains trailing or leading quotes, enclose it
+ with an extra pair of quotes, for example \cb{'\"x\"'}. Non-leading
+ and non-trailing quotes are interpreted as being part of the option
+ value.
+
+ The semantics of providing options in a file is equivalent to providing
+ the same set of options in the same order on the command line at the
+ point where the \cb{--options-file} option is specified except that
+ the shell escaping and quoting is not required. You can repeat this
+ option to specify more than one options file."
+ };
+
+ // SLOC/license options.
+ //
+ bool --show-sloc
+ {
+ "Show the number of generated physical source lines of code (SLOC)."
+ };
+
+ std::size_t --sloc-limit
+ {
+ "<num>",
+ "Check that the number of generated physical source lines of code (SLOC)
+ does not exceed <num>."
+ };
+
+ bool --proprietary-license
+ {
+ "Indicate that the generated code is licensed under a proprietary
+ license instead of the GPL."
+ };
+
+ NarrowString --custom-literals
+ {
+ "<file>",
+ "Load custom XML string to C++ literal mappings from <file>. This
+ mechanism can be useful if you are using a custom character encoding
+ and some of the strings in your schemas, for example element/attribute
+ names or enumeration values, contain non-ASCII characters. In this
+ case you will need to provide a custom mapping to C++ literals for
+ such strings. The format of this file is specified in the
+ \cb{custom-literals.xsd} XML Schema file that can be found in the
+ documentation directory."
+ };
+
+ // Anonymous type morphing.
+ //
+ bool --preserve-anonymous
+ {
+ "Preserve anonymous types. By default anonymous types are automatically
+ named with names derived from the enclosing elements/attributes. Because
+ mappings implemented by this compiler require all types to be named,
+ this option is only useful if you want to make sure your schemas don't
+ have anonymous types."
+ };
+
+ bool --show-anonymous
+ {
+ "Show elements and attributes that are of anonymous types. This option
+ only makes sense together with the \cb{--preserve-anonymous} option."
+ };
+
+ NarrowStrings --anonymous-regex
+ {
+ "<regex>",
+ "Add <regex> to the list of regular expressions used to derive names for
+ anonymous types from the enclosing attributes/elements. <regex> is a
+ Perl-like regular expression in the form
+ \c{\b{/}\i{pattern}\b{/}\i{replacement}\b{/}}.
+ Any character can be used as a delimiter instead of \cb{/}. Escaping of
+ the delimiter character in \ci{pattern} or \ci{replacement} is not
+ supported.
+
+ All the regular expressions are pushed into a stack with the last
+ specified expression considered first. The first match that succeeds is
+ used. Regular expressions are applied to a string in the form
+
+ \c{\i{filename} \i{namespace} \i{xpath}}
+
+ For instance:
+
+ \cb{hello.xsd http://example.com/hello element}
+
+ \cb{hello.xsd http://example.com/hello type/element}
+
+ As an example, the following expression makes all the derived names
+ start with capital letters. This could be useful when your naming
+ convention requires type names to start with capital letters:
+
+ \cb{%.* .* (.+/)*(.+)%\\u$2%}
+
+ See also the REGEX AND SHELL QUOTING section below."
+ };
+
+ bool --anonymous-regex-trace
+ {
+ "Trace the process of applying regular expressions specified with the
+ \cb{--anonymous-regex} option. Use this option to find out why your
+ regular expressions don't do what you expected them to do."
+ };
+
+ bool --morph-anonymous; // Deprecated and therefore undocumented.
+
+ // Location options.
+ //
+ NarrowStrings --location-map
+ {
+ "<ol>=<nl>",
+ "Map the original schema location <ol> that is specified in the XML
+ Schema include or import elements to new schema location <nl>. Repeat
+ this option to map more than one schema location. For example, the
+ following option maps the \cb{http://example.com/foo.xsd} URL to the
+ \cb{foo.xsd} local file.
+
+ \cb{--location-map http://example.com/foo.xsd=foo.xsd}"
+ };
+
+ NarrowStrings --location-regex
+ {
+ "<regex>",
+ "Add <regex> to the list of regular expressions used to map schema
+ locations that are specified in the XML Schema include or import
+ elements. <regex> is a Perl-like regular expression in the form
+ \c{\b{/}\i{pattern}\b{/}\i{replacement}\b{/}}. Any character can
+ be used as a delimiter instead of \cb{/}. Escaping of the delimiter
+ character in \ci{pattern} or \ci{replacement} is not supported. All
+ the regular expressions are pushed into a stack with the last specified
+ expression considered first. The first match that succeeds is used.
+
+ For example, the following expression maps URL locations in the form
+ \cb{http://example.com/foo/bar.xsd} to local files in the form
+ \cb{bar.xsd}:
+
+ \cb{%http://.+/(.+)%$1%}
+
+ See also the REGEX AND SHELL QUOTING section below."
+ };
+
+ bool --location-regex-trace
+ {
+ "Trace the process of applying regular expressions specified with the
+ \cb{--location-regex} option. Use this option to find out why your
+ regular expressions don't do what you expected them to do."
+ };
+
+ // File-per-type option.
+ //
+ bool --file-per-type
+ {
+ "Generate a separate set of C++ files for each type defined in XML
+ Schema. Note that in this mode you only need to compile the root
+ schema(s) and the code will be generated for all included and
+ imported schemas. This compilation mode is primarily useful when
+ some of your schemas cannot be compiled separately or have cyclic
+ dependencies which involve type inheritance. Other options related
+ to this mode are: \cb{--type-file-regex}, \cb{--schema-file-regex},
+ \cb{--fat-type-file}, and \cb{--file-list}."
+ };
+
+ NarrowStrings --type-file-regex
+ {
+ "<regex>",
+ "Add <regex> to the list of regular expressions used to translate type
+ names to file names when the \cb{--file-per-type} option is specified.
+ <regex> is a Perl-like regular expression in the form
+ \c{\b{/}\i{pattern}\b{/}\i{replacement}\b{/}}. Any character can be
+ used as a delimiter instead of \cb{/}. Escaping of the delimiter
+ character in \ci{pattern} or \ci{replacement} is not supported. All
+ the regular expressions are pushed into a stack with the last specified
+ expression considered first. The first match that succeeds is used.
+ Regular expressions are applied to a string in the form
+
+ \c{\i{namespace} \i{type-name}}
+
+ For example, the following expression maps type \cb{foo} that is
+ defined in the \cb{http://example.com/bar} namespace to file name
+ \cb{bar-foo}:
+
+ \cb{%http://example.com/(.+) (.+)%$1-$2%}
+
+ See also the REGEX AND SHELL QUOTING section below."
+ };
+
+ bool --type-file-regex-trace
+ {
+ "Trace the process of applying regular expressions specified with the
+ \cb{--type-file-regex} option. Use this option to find out why your
+ regular expressions don't do what you expected them to do."
+ };
+
+ NarrowStrings --schema-file-regex
+ {
+ "<regex>",
+ "Add <regex> to the list of regular expressions used to translate schema
+ file names when the \cb{--file-per-type} option is specified. <regex> is
+ a Perl-like regular expression in the form
+ \c{\b{/}\i{pattern}\b{/}\i{replacement}\b{/}}. Any character can be used
+ as a delimiter instead of \cb{/}. Escaping of the delimiter character in
+ \ci{pattern} or \ci{replacement} is not supported. All the regular
+ expressions are pushed into a stack with the last specified expression
+ considered first. The first match that succeeds is used. Regular
+ Expressions are applied to the absolute filesystem path of a schema file
+ and the result, including the directory part, if any, is used to derive
+ the \cb{#include} directive paths as well as the generated C++ file
+ paths. This option, along with \cb{--type-file-regex} are primarily
+ useful to place the generated files into subdirectories or to resolve
+ file name conflicts.
+
+ For example, the following expression maps schema files in the
+ \cb{foo/1.0.0/} subdirectory to the files in the \cb{foo/} subdirectory.
+ As a result, the \cb{#include} directive paths for such schemas will be
+ in the \cb{foo/schema.hxx} form and the generated C++ files will be
+ placed into the \cb{foo/} subdirectory:
+
+ \cb{%.*/foo/1.0.0/(.+)%foo/$1%}
+
+ See also the REGEX AND SHELL QUOTING section below."
+ };
+
+ bool --schema-file-regex-trace
+ {
+ "Trace the process of applying regular expressions specified with the
+ \cb{--schema-file-regex} option. Use this option to find out why your
+ regular expressions don't do what you expected them to do."
+ };
+
+ bool --fat-type-file
+ {
+ "Generate code corresponding to global elements into type files instead
+ of schema files when the \cb{--type-file-regex} option is specified.
+ This option is primarily useful when trying to minimize the amount of
+ object code that is linked to an executable by packaging compiled
+ generated code into a static (archive) library."
+ };
+
+ // File list options.
+ //
+ NarrowString --file-list
+ {
+ "<file>",
+ "Write a list of generated C++ files to <file>. This option is primarily
+ useful in the file-per-type compilation mode (\cb{--file-per-type}) to
+ create a list of generated C++ files, for example, as a makefile
+ fragment."
+ };
+
+ NarrowString --file-list-prologue
+ {
+ "<text>",
+ "Insert <text> at the beginning of the file list. As a convenience, all
+ occurrences of the \cb{\\n} character sequence in <text> are replaced
+ with new lines. This option can, for example, be used to assign the
+ generated file list to a makefile variable."
+ };
+
+ NarrowString --file-list-epilogue
+ {
+ "<text>",
+ "Insert <text> at the end of the file list. As a convenience, all
+ occurrences of the \cb{\\n} character sequence in <text> are replaced
+ with new lines."
+ };
+
+ NarrowString --file-list-delim = "\n"
+ {
+ "<text>",
+ "Delimit file names written to the file list with <text> instead of new
+ lines. As a convenience, all occurrences of the \cb{\\n} character
+ sequence in <text> are replaced with new lines."
+ };
+
+ // Undocumented.
+ //
+ bool --disable-multi-import;
+ bool --disable-full-check;
+};
diff --git a/xsd/xsd/options.cxx b/xsd/xsd/options.cxx
new file mode 100644
index 0000000..3af99f2
--- /dev/null
+++ b/xsd/xsd/options.cxx
@@ -0,0 +1,976 @@
+// This code was generated by CLI, a command line interface
+// compiler for C++.
+//
+
+// Begin prologue.
+//
+#include <options-parser.hxx>
+//
+// End prologue.
+
+#include <options.hxx>
+
+#include <map>
+#include <set>
+#include <string>
+#include <vector>
+#include <ostream>
+#include <sstream>
+#include <cstring>
+#include <fstream>
+
+namespace cli
+{
+ // unknown_option
+ //
+ unknown_option::
+ ~unknown_option () throw ()
+ {
+ }
+
+ void unknown_option::
+ print (::std::wostream& os) const
+ {
+ os << "unknown option '" << option ().c_str () << "'";
+ }
+
+ const char* unknown_option::
+ what () const throw ()
+ {
+ return "unknown option";
+ }
+
+ // unknown_argument
+ //
+ unknown_argument::
+ ~unknown_argument () throw ()
+ {
+ }
+
+ void unknown_argument::
+ print (::std::wostream& os) const
+ {
+ os << "unknown argument '" << argument ().c_str () << "'";
+ }
+
+ const char* unknown_argument::
+ what () const throw ()
+ {
+ return "unknown argument";
+ }
+
+ // missing_value
+ //
+ missing_value::
+ ~missing_value () throw ()
+ {
+ }
+
+ void missing_value::
+ print (::std::wostream& os) const
+ {
+ os << "missing value for option '" << option ().c_str () << "'";
+ }
+
+ const char* missing_value::
+ what () const throw ()
+ {
+ return "missing option value";
+ }
+
+ // invalid_value
+ //
+ invalid_value::
+ ~invalid_value () throw ()
+ {
+ }
+
+ void invalid_value::
+ print (::std::wostream& os) const
+ {
+ os << "invalid value '" << value ().c_str () << "' for option '"
+ << option ().c_str () << "'";
+ }
+
+ const char* invalid_value::
+ what () const throw ()
+ {
+ return "invalid option value";
+ }
+
+ // eos_reached
+ //
+ void eos_reached::
+ print (::std::wostream& os) const
+ {
+ os << what ();
+ }
+
+ const char* eos_reached::
+ what () const throw ()
+ {
+ return "end of argument stream reached";
+ }
+
+ // file_io_failure
+ //
+ file_io_failure::
+ ~file_io_failure () throw ()
+ {
+ }
+
+ void file_io_failure::
+ print (::std::wostream& os) const
+ {
+ os << "unable to open file '" << file ().c_str () << "' or read failure";
+ }
+
+ const char* file_io_failure::
+ what () const throw ()
+ {
+ return "unable to open file or read failure";
+ }
+
+ // unmatched_quote
+ //
+ unmatched_quote::
+ ~unmatched_quote () throw ()
+ {
+ }
+
+ void unmatched_quote::
+ print (::std::wostream& os) const
+ {
+ os << "unmatched quote in argument '" << argument ().c_str () << "'";
+ }
+
+ const char* unmatched_quote::
+ what () const throw ()
+ {
+ return "unmatched quote";
+ }
+
+ // scanner
+ //
+ scanner::
+ ~scanner ()
+ {
+ }
+
+ // argv_scanner
+ //
+ bool argv_scanner::
+ more ()
+ {
+ return i_ < argc_;
+ }
+
+ const char* argv_scanner::
+ peek ()
+ {
+ if (i_ < argc_)
+ return argv_[i_];
+ else
+ throw eos_reached ();
+ }
+
+ const char* argv_scanner::
+ next ()
+ {
+ if (i_ < argc_)
+ {
+ const char* r (argv_[i_]);
+
+ if (erase_)
+ {
+ for (int i (i_ + 1); i < argc_; ++i)
+ argv_[i - 1] = argv_[i];
+
+ --argc_;
+ argv_[argc_] = 0;
+ }
+ else
+ ++i_;
+
+ return r;
+ }
+ else
+ throw eos_reached ();
+ }
+
+ void argv_scanner::
+ skip ()
+ {
+ if (i_ < argc_)
+ ++i_;
+ else
+ throw eos_reached ();
+ }
+
+ // argv_file_scanner
+ //
+ bool argv_file_scanner::
+ more ()
+ {
+ if (!args_.empty ())
+ return true;
+
+ while (base::more ())
+ {
+ // See if the next argument is the file option.
+ //
+ const char* a (base::peek ());
+ const option_info* oi;
+
+ if (!skip_ && (oi = find (a)))
+ {
+ base::next ();
+
+ if (!base::more ())
+ throw missing_value (oi->option);
+
+ if (oi->search_func != 0)
+ {
+ std::string f (oi->search_func (base::next (), oi->arg));
+
+ if (!f.empty ())
+ load (f);
+ }
+ else
+ load (base::next ());
+
+ if (!args_.empty ())
+ return true;
+ }
+ else
+ {
+ if (!skip_)
+ skip_ = (std::strcmp (a, "--") == 0);
+
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ const char* argv_file_scanner::
+ peek ()
+ {
+ if (!more ())
+ throw eos_reached ();
+
+ return args_.empty () ? base::peek () : args_.front ().c_str ();
+ }
+
+ const char* argv_file_scanner::
+ next ()
+ {
+ if (!more ())
+ throw eos_reached ();
+
+ if (args_.empty ())
+ return base::next ();
+ else
+ {
+ hold_.swap (args_.front ());
+ args_.pop_front ();
+ return hold_.c_str ();
+ }
+ }
+
+ void argv_file_scanner::
+ skip ()
+ {
+ if (!more ())
+ throw eos_reached ();
+
+ if (args_.empty ())
+ return base::skip ();
+ else
+ args_.pop_front ();
+ }
+
+ const argv_file_scanner::option_info* argv_file_scanner::
+ find (const char* a) const
+ {
+ for (std::size_t i (0); i < options_count_; ++i)
+ if (std::strcmp (a, options_[i].option) == 0)
+ return &options_[i];
+
+ return 0;
+ }
+
+ void argv_file_scanner::
+ load (const std::string& file)
+ {
+ using namespace std;
+
+ ifstream is (file.c_str ());
+
+ if (!is.is_open ())
+ throw file_io_failure (file);
+
+ while (!is.eof ())
+ {
+ string line;
+ getline (is, line);
+
+ if (is.fail () && !is.eof ())
+ throw file_io_failure (file);
+
+ string::size_type n (line.size ());
+
+ // Trim the line from leading and trailing whitespaces.
+ //
+ if (n != 0)
+ {
+ const char* f (line.c_str ());
+ const char* l (f + n);
+
+ const char* of (f);
+ while (f < l && (*f == ' ' || *f == '\t' || *f == '\r'))
+ ++f;
+
+ --l;
+
+ const char* ol (l);
+ while (l > f && (*l == ' ' || *l == '\t' || *l == '\r'))
+ --l;
+
+ if (f != of || l != ol)
+ line = f <= l ? string (f, l - f + 1) : string ();
+ }
+
+ // Ignore empty lines, those that start with #.
+ //
+ if (line.empty () || line[0] == '#')
+ continue;
+
+ string::size_type p (line.find (' '));
+
+ if (p == string::npos)
+ {
+ if (!skip_)
+ skip_ = (line == "--");
+
+ args_.push_back (line);
+ }
+ else
+ {
+ string s1 (line, 0, p);
+
+ // Skip leading whitespaces in the argument.
+ //
+ n = line.size ();
+ for (++p; p < n; ++p)
+ {
+ char c (line[p]);
+
+ if (c != ' ' && c != '\t' && c != '\r')
+ break;
+ }
+
+ string s2 (line, p);
+
+ // If the string is wrapped in quotes, remove them.
+ //
+ n = s2.size ();
+ char cf (s2[0]), cl (s2[n - 1]);
+
+ if (cf == '"' || cf == '\'' || cl == '"' || cl == '\'')
+ {
+ if (n == 1 || cf != cl)
+ throw unmatched_quote (s2);
+
+ s2 = string (s2, 1, n - 2);
+ }
+
+ const option_info* oi;
+ if (!skip_ && (oi = find (s1.c_str ())))
+ {
+ if (s2.empty ())
+ throw missing_value (oi->option);
+
+ if (oi->search_func != 0)
+ {
+ std::string f (oi->search_func (s2.c_str (), oi->arg));
+
+ if (!f.empty ())
+ load (f);
+ }
+ else
+ load (s2);
+ }
+ else
+ {
+ args_.push_back (s1);
+ args_.push_back (s2);
+ }
+ }
+ }
+ }
+
+ template <typename X>
+ struct parser
+ {
+ static void
+ parse (X& x, bool& xs, scanner& s)
+ {
+ std::string o (s.next ());
+
+ if (s.more ())
+ {
+ std::string v (s.next ());
+ std::istringstream is (v);
+ if (!(is >> x && is.eof ()))
+ throw invalid_value (o, v);
+ }
+ else
+ throw missing_value (o);
+
+ xs = true;
+ }
+ };
+
+ template <>
+ struct parser<bool>
+ {
+ static void
+ parse (bool& x, scanner& s)
+ {
+ s.next ();
+ x = true;
+ }
+ };
+
+ template <>
+ struct parser<std::string>
+ {
+ static void
+ parse (std::string& x, bool& xs, scanner& s)
+ {
+ const char* o (s.next ());
+
+ if (s.more ())
+ x = s.next ();
+ else
+ throw missing_value (o);
+
+ xs = true;
+ }
+ };
+
+ template <typename X>
+ struct parser<std::vector<X> >
+ {
+ static void
+ parse (std::vector<X>& c, bool& xs, scanner& s)
+ {
+ X x;
+ bool dummy;
+ parser<X>::parse (x, dummy, s);
+ c.push_back (x);
+ xs = true;
+ }
+ };
+
+ template <typename X>
+ struct parser<std::set<X> >
+ {
+ static void
+ parse (std::set<X>& c, bool& xs, scanner& s)
+ {
+ X x;
+ bool dummy;
+ parser<X>::parse (x, dummy, s);
+ c.insert (x);
+ xs = true;
+ }
+ };
+
+ template <typename K, typename V>
+ struct parser<std::map<K, V> >
+ {
+ static void
+ parse (std::map<K, V>& m, bool& xs, scanner& s)
+ {
+ std::string o (s.next ());
+
+ if (s.more ())
+ {
+ std::string ov (s.next ());
+ std::string::size_type p = ov.find ('=');
+
+ if (p == std::string::npos)
+ {
+ K k = K ();
+
+ if (!ov.empty ())
+ {
+ std::istringstream ks (ov);
+
+ if (!(ks >> k && ks.eof ()))
+ throw invalid_value (o, ov);
+ }
+
+ m[k] = V ();
+ }
+ else
+ {
+ K k = K ();
+ V v = V ();
+ std::string kstr (ov, 0, p);
+ std::string vstr (ov, p + 1);
+
+ if (!kstr.empty ())
+ {
+ std::istringstream ks (kstr);
+
+ if (!(ks >> k && ks.eof ()))
+ throw invalid_value (o, ov);
+ }
+
+ if (!vstr.empty ())
+ {
+ std::istringstream vs (vstr);
+
+ if (!(vs >> v && vs.eof ()))
+ throw invalid_value (o, ov);
+ }
+
+ m[k] = v;
+ }
+ }
+ else
+ throw missing_value (o);
+
+ xs = true;
+ }
+ };
+
+ template <typename X, typename T, T X::*M>
+ void
+ thunk (X& x, scanner& s)
+ {
+ parser<T>::parse (x.*M, s);
+ }
+
+ template <typename X, typename T, T X::*M, bool X::*S>
+ void
+ thunk (X& x, scanner& s)
+ {
+ parser<T>::parse (x.*M, x.*S, s);
+ }
+}
+
+#include <map>
+#include <cstring>
+
+// help_options
+//
+
+help_options::
+help_options ()
+: help_ (),
+ version_ (),
+ proprietary_license_ ()
+{
+}
+
+help_options::
+help_options (int& argc,
+ char** argv,
+ bool erase,
+ ::cli::unknown_mode opt,
+ ::cli::unknown_mode arg)
+: help_ (),
+ version_ (),
+ proprietary_license_ ()
+{
+ ::cli::argv_scanner s (argc, argv, erase);
+ _parse (s, opt, arg);
+}
+
+help_options::
+help_options (int start,
+ int& argc,
+ char** argv,
+ bool erase,
+ ::cli::unknown_mode opt,
+ ::cli::unknown_mode arg)
+: help_ (),
+ version_ (),
+ proprietary_license_ ()
+{
+ ::cli::argv_scanner s (start, argc, argv, erase);
+ _parse (s, opt, arg);
+}
+
+help_options::
+help_options (int& argc,
+ char** argv,
+ int& end,
+ bool erase,
+ ::cli::unknown_mode opt,
+ ::cli::unknown_mode arg)
+: help_ (),
+ version_ (),
+ proprietary_license_ ()
+{
+ ::cli::argv_scanner s (argc, argv, erase);
+ _parse (s, opt, arg);
+ end = s.end ();
+}
+
+help_options::
+help_options (int start,
+ int& argc,
+ char** argv,
+ int& end,
+ bool erase,
+ ::cli::unknown_mode opt,
+ ::cli::unknown_mode arg)
+: help_ (),
+ version_ (),
+ proprietary_license_ ()
+{
+ ::cli::argv_scanner s (start, argc, argv, erase);
+ _parse (s, opt, arg);
+ end = s.end ();
+}
+
+help_options::
+help_options (::cli::scanner& s,
+ ::cli::unknown_mode opt,
+ ::cli::unknown_mode arg)
+: help_ (),
+ version_ (),
+ proprietary_license_ ()
+{
+ _parse (s, opt, arg);
+}
+
+void help_options::
+print_usage (::std::wostream&)
+{
+}
+
+typedef
+std::map<std::string, void (*) (help_options&, ::cli::scanner&)>
+_cli_help_options_map;
+
+static _cli_help_options_map _cli_help_options_map_;
+
+struct _cli_help_options_map_init
+{
+ _cli_help_options_map_init ()
+ {
+ _cli_help_options_map_["--help"] =
+ &::cli::thunk< help_options, bool, &help_options::help_ >;
+ _cli_help_options_map_["--version"] =
+ &::cli::thunk< help_options, bool, &help_options::version_ >;
+ _cli_help_options_map_["--proprietary-license"] =
+ &::cli::thunk< help_options, bool, &help_options::proprietary_license_ >;
+ }
+};
+
+static _cli_help_options_map_init _cli_help_options_map_init_;
+
+bool help_options::
+_parse (const char* o, ::cli::scanner& s)
+{
+ _cli_help_options_map::const_iterator i (_cli_help_options_map_.find (o));
+
+ if (i != _cli_help_options_map_.end ())
+ {
+ (*(i->second)) (*this, s);
+ return true;
+ }
+
+ return false;
+}
+
+void help_options::
+_parse (::cli::scanner& s,
+ ::cli::unknown_mode opt_mode,
+ ::cli::unknown_mode arg_mode)
+{
+ bool opt = true;
+
+ while (s.more ())
+ {
+ const char* o = s.peek ();
+
+ if (std::strcmp (o, "--") == 0)
+ {
+ s.skip ();
+ opt = false;
+ continue;
+ }
+
+ if (opt && _parse (o, s));
+ else if (opt && std::strncmp (o, "-", 1) == 0 && o[1] != '\0')
+ {
+ switch (opt_mode)
+ {
+ case ::cli::unknown_mode::skip:
+ {
+ s.skip ();
+ continue;
+ }
+ case ::cli::unknown_mode::stop:
+ {
+ break;
+ }
+ case ::cli::unknown_mode::fail:
+ {
+ throw ::cli::unknown_option (o);
+ }
+ }
+
+ break;
+ }
+ else
+ {
+ switch (arg_mode)
+ {
+ case ::cli::unknown_mode::skip:
+ {
+ s.skip ();
+ continue;
+ }
+ case ::cli::unknown_mode::stop:
+ {
+ break;
+ }
+ case ::cli::unknown_mode::fail:
+ {
+ throw ::cli::unknown_argument (o);
+ }
+ }
+
+ break;
+ }
+ }
+}
+
+// options
+//
+
+options::
+options ()
+: disable_warning_ (),
+ disable_warning_specified_ (false),
+ options_file_ (),
+ options_file_specified_ (false),
+ show_sloc_ (),
+ sloc_limit_ (),
+ sloc_limit_specified_ (false),
+ proprietary_license_ (),
+ custom_literals_ (),
+ custom_literals_specified_ (false),
+ preserve_anonymous_ (),
+ show_anonymous_ (),
+ anonymous_regex_ (),
+ anonymous_regex_specified_ (false),
+ anonymous_regex_trace_ (),
+ morph_anonymous_ (),
+ location_map_ (),
+ location_map_specified_ (false),
+ location_regex_ (),
+ location_regex_specified_ (false),
+ location_regex_trace_ (),
+ file_per_type_ (),
+ type_file_regex_ (),
+ type_file_regex_specified_ (false),
+ type_file_regex_trace_ (),
+ schema_file_regex_ (),
+ schema_file_regex_specified_ (false),
+ schema_file_regex_trace_ (),
+ fat_type_file_ (),
+ file_list_ (),
+ file_list_specified_ (false),
+ file_list_prologue_ (),
+ file_list_prologue_specified_ (false),
+ file_list_epilogue_ (),
+ file_list_epilogue_specified_ (false),
+ file_list_delim_ ("\n"),
+ file_list_delim_specified_ (false),
+ disable_multi_import_ (),
+ disable_full_check_ ()
+{
+}
+
+void options::
+print_usage (::std::wostream& os)
+{
+ os << "--disable-warning <warn> Disable printing warning with id <warn>." << ::std::endl;
+
+ os << "--options-file <file> Read additional options from <file>." << ::std::endl;
+
+ os << "--show-sloc Show the number of generated physical source lines" << ::std::endl
+ << " of code (SLOC)." << ::std::endl;
+
+ os << "--sloc-limit <num> Check that the number of generated physical source" << ::std::endl
+ << " lines of code (SLOC) does not exceed <num>." << ::std::endl;
+
+ os << "--proprietary-license Indicate that the generated code is licensed under" << ::std::endl
+ << " a proprietary license instead of the GPL." << ::std::endl;
+
+ os << "--custom-literals <file> Load custom XML string to C++ literal mappings" << ::std::endl
+ << " from <file>." << ::std::endl;
+
+ os << "--preserve-anonymous Preserve anonymous types." << ::std::endl;
+
+ os << "--show-anonymous Show elements and attributes that are of anonymous" << ::std::endl
+ << " types." << ::std::endl;
+
+ os << "--anonymous-regex <regex> Add <regex> to the list of regular expressions" << ::std::endl
+ << " used to derive names for anonymous types from the" << ::std::endl
+ << " enclosing attributes/elements." << ::std::endl;
+
+ os << "--anonymous-regex-trace Trace the process of applying regular expressions" << ::std::endl
+ << " specified with the '--anonymous-regex' option." << ::std::endl;
+
+ os << "--location-map <ol>=<nl> Map the original schema location <ol> that is" << ::std::endl
+ << " specified in the XML Schema include or import" << ::std::endl
+ << " elements to new schema location <nl>." << ::std::endl;
+
+ os << "--location-regex <regex> Add <regex> to the list of regular expressions" << ::std::endl
+ << " used to map schema locations that are specified in" << ::std::endl
+ << " the XML Schema include or import elements." << ::std::endl;
+
+ os << "--location-regex-trace Trace the process of applying regular expressions" << ::std::endl
+ << " specified with the '--location-regex' option." << ::std::endl;
+
+ os << "--file-per-type Generate a separate set of C++ files for each type" << ::std::endl
+ << " defined in XML Schema." << ::std::endl;
+
+ os << "--type-file-regex <regex> Add <regex> to the list of regular expressions" << ::std::endl
+ << " used to translate type names to file names when" << ::std::endl
+ << " the '--file-per-type' option is specified." << ::std::endl;
+
+ os << "--type-file-regex-trace Trace the process of applying regular expressions" << ::std::endl
+ << " specified with the '--type-file-regex' option." << ::std::endl;
+
+ os << "--schema-file-regex <regex> Add <regex> to the list of regular expressions" << ::std::endl
+ << " used to translate schema file names when the" << ::std::endl
+ << " '--file-per-type' option is specified." << ::std::endl;
+
+ os << "--schema-file-regex-trace Trace the process of applying regular expressions" << ::std::endl
+ << " specified with the '--schema-file-regex' option." << ::std::endl;
+
+ os << "--fat-type-file Generate code corresponding to global elements" << ::std::endl
+ << " into type files instead of schema files when the" << ::std::endl
+ << " '--type-file-regex' option is specified." << ::std::endl;
+
+ os << "--file-list <file> Write a list of generated C++ files to <file>." << ::std::endl;
+
+ os << "--file-list-prologue <text> Insert <text> at the beginning of the file list." << ::std::endl;
+
+ os << "--file-list-epilogue <text> Insert <text> at the end of the file list." << ::std::endl;
+
+ os << "--file-list-delim <text> Delimit file names written to the file list with" << ::std::endl
+ << " <text> instead of new lines." << ::std::endl;
+}
+
+typedef
+std::map<std::string, void (*) (options&, ::cli::scanner&)>
+_cli_options_map;
+
+static _cli_options_map _cli_options_map_;
+
+struct _cli_options_map_init
+{
+ _cli_options_map_init ()
+ {
+ _cli_options_map_["--disable-warning"] =
+ &::cli::thunk< options, NarrowStrings, &options::disable_warning_,
+ &options::disable_warning_specified_ >;
+ _cli_options_map_["--options-file"] =
+ &::cli::thunk< options, std::string, &options::options_file_,
+ &options::options_file_specified_ >;
+ _cli_options_map_["--show-sloc"] =
+ &::cli::thunk< options, bool, &options::show_sloc_ >;
+ _cli_options_map_["--sloc-limit"] =
+ &::cli::thunk< options, std::size_t, &options::sloc_limit_,
+ &options::sloc_limit_specified_ >;
+ _cli_options_map_["--proprietary-license"] =
+ &::cli::thunk< options, bool, &options::proprietary_license_ >;
+ _cli_options_map_["--custom-literals"] =
+ &::cli::thunk< options, NarrowString, &options::custom_literals_,
+ &options::custom_literals_specified_ >;
+ _cli_options_map_["--preserve-anonymous"] =
+ &::cli::thunk< options, bool, &options::preserve_anonymous_ >;
+ _cli_options_map_["--show-anonymous"] =
+ &::cli::thunk< options, bool, &options::show_anonymous_ >;
+ _cli_options_map_["--anonymous-regex"] =
+ &::cli::thunk< options, NarrowStrings, &options::anonymous_regex_,
+ &options::anonymous_regex_specified_ >;
+ _cli_options_map_["--anonymous-regex-trace"] =
+ &::cli::thunk< options, bool, &options::anonymous_regex_trace_ >;
+ _cli_options_map_["--morph-anonymous"] =
+ &::cli::thunk< options, bool, &options::morph_anonymous_ >;
+ _cli_options_map_["--location-map"] =
+ &::cli::thunk< options, NarrowStrings, &options::location_map_,
+ &options::location_map_specified_ >;
+ _cli_options_map_["--location-regex"] =
+ &::cli::thunk< options, NarrowStrings, &options::location_regex_,
+ &options::location_regex_specified_ >;
+ _cli_options_map_["--location-regex-trace"] =
+ &::cli::thunk< options, bool, &options::location_regex_trace_ >;
+ _cli_options_map_["--file-per-type"] =
+ &::cli::thunk< options, bool, &options::file_per_type_ >;
+ _cli_options_map_["--type-file-regex"] =
+ &::cli::thunk< options, NarrowStrings, &options::type_file_regex_,
+ &options::type_file_regex_specified_ >;
+ _cli_options_map_["--type-file-regex-trace"] =
+ &::cli::thunk< options, bool, &options::type_file_regex_trace_ >;
+ _cli_options_map_["--schema-file-regex"] =
+ &::cli::thunk< options, NarrowStrings, &options::schema_file_regex_,
+ &options::schema_file_regex_specified_ >;
+ _cli_options_map_["--schema-file-regex-trace"] =
+ &::cli::thunk< options, bool, &options::schema_file_regex_trace_ >;
+ _cli_options_map_["--fat-type-file"] =
+ &::cli::thunk< options, bool, &options::fat_type_file_ >;
+ _cli_options_map_["--file-list"] =
+ &::cli::thunk< options, NarrowString, &options::file_list_,
+ &options::file_list_specified_ >;
+ _cli_options_map_["--file-list-prologue"] =
+ &::cli::thunk< options, NarrowString, &options::file_list_prologue_,
+ &options::file_list_prologue_specified_ >;
+ _cli_options_map_["--file-list-epilogue"] =
+ &::cli::thunk< options, NarrowString, &options::file_list_epilogue_,
+ &options::file_list_epilogue_specified_ >;
+ _cli_options_map_["--file-list-delim"] =
+ &::cli::thunk< options, NarrowString, &options::file_list_delim_,
+ &options::file_list_delim_specified_ >;
+ _cli_options_map_["--disable-multi-import"] =
+ &::cli::thunk< options, bool, &options::disable_multi_import_ >;
+ _cli_options_map_["--disable-full-check"] =
+ &::cli::thunk< options, bool, &options::disable_full_check_ >;
+ }
+};
+
+static _cli_options_map_init _cli_options_map_init_;
+
+bool options::
+_parse (const char* o, ::cli::scanner& s)
+{
+ _cli_options_map::const_iterator i (_cli_options_map_.find (o));
+
+ if (i != _cli_options_map_.end ())
+ {
+ (*(i->second)) (*this, s);
+ return true;
+ }
+
+ return false;
+}
+
+// Begin epilogue.
+//
+//
+// End epilogue.
+
diff --git a/xsd/xsd/options.hxx b/xsd/xsd/options.hxx
new file mode 100644
index 0000000..ed243bc
--- /dev/null
+++ b/xsd/xsd/options.hxx
@@ -0,0 +1,575 @@
+// This code was generated by CLI, a command line interface
+// compiler for C++.
+//
+
+#ifndef OPTIONS_HXX
+#define OPTIONS_HXX
+
+// Begin prologue.
+//
+//
+// End prologue.
+
+#include <deque>
+#include <iosfwd>
+#include <string>
+#include <cstddef>
+#include <exception>
+
+namespace cli
+{
+ class unknown_mode
+ {
+ public:
+ enum value
+ {
+ skip,
+ stop,
+ fail
+ };
+
+ unknown_mode (value v);
+
+ operator value () const
+ {
+ return v_;
+ }
+
+ private:
+ value v_;
+ };
+
+ // Exceptions.
+ //
+
+ class exception: public std::exception
+ {
+ public:
+ virtual void
+ print (::std::wostream&) const = 0;
+ };
+
+ ::std::wostream&
+ operator<< (::std::wostream&, const exception&);
+
+ class unknown_option: public exception
+ {
+ public:
+ virtual
+ ~unknown_option () throw ();
+
+ unknown_option (const std::string& option);
+
+ const std::string&
+ option () const;
+
+ virtual void
+ print (::std::wostream&) const;
+
+ virtual const char*
+ what () const throw ();
+
+ private:
+ std::string option_;
+ };
+
+ class unknown_argument: public exception
+ {
+ public:
+ virtual
+ ~unknown_argument () throw ();
+
+ unknown_argument (const std::string& argument);
+
+ const std::string&
+ argument () const;
+
+ virtual void
+ print (::std::wostream&) const;
+
+ virtual const char*
+ what () const throw ();
+
+ private:
+ std::string argument_;
+ };
+
+ class missing_value: public exception
+ {
+ public:
+ virtual
+ ~missing_value () throw ();
+
+ missing_value (const std::string& option);
+
+ const std::string&
+ option () const;
+
+ virtual void
+ print (::std::wostream&) const;
+
+ virtual const char*
+ what () const throw ();
+
+ private:
+ std::string option_;
+ };
+
+ class invalid_value: public exception
+ {
+ public:
+ virtual
+ ~invalid_value () throw ();
+
+ invalid_value (const std::string& option,
+ const std::string& value);
+
+ const std::string&
+ option () const;
+
+ const std::string&
+ value () const;
+
+ virtual void
+ print (::std::wostream&) const;
+
+ virtual const char*
+ what () const throw ();
+
+ private:
+ std::string option_;
+ std::string value_;
+ };
+
+ class eos_reached: public exception
+ {
+ public:
+ virtual void
+ print (::std::wostream&) const;
+
+ virtual const char*
+ what () const throw ();
+ };
+
+ class file_io_failure: public exception
+ {
+ public:
+ virtual
+ ~file_io_failure () throw ();
+
+ file_io_failure (const std::string& file);
+
+ const std::string&
+ file () const;
+
+ virtual void
+ print (::std::wostream&) const;
+
+ virtual const char*
+ what () const throw ();
+
+ private:
+ std::string file_;
+ };
+
+ class unmatched_quote: public exception
+ {
+ public:
+ virtual
+ ~unmatched_quote () throw ();
+
+ unmatched_quote (const std::string& argument);
+
+ const std::string&
+ argument () const;
+
+ virtual void
+ print (::std::wostream&) const;
+
+ virtual const char*
+ what () const throw ();
+
+ private:
+ std::string argument_;
+ };
+
+ class scanner
+ {
+ public:
+ virtual
+ ~scanner ();
+
+ virtual bool
+ more () = 0;
+
+ virtual const char*
+ peek () = 0;
+
+ virtual const char*
+ next () = 0;
+
+ virtual void
+ skip () = 0;
+ };
+
+ class argv_scanner: public scanner
+ {
+ public:
+ argv_scanner (int& argc, char** argv, bool erase = false);
+ argv_scanner (int start, int& argc, char** argv, bool erase = false);
+
+ int
+ end () const;
+
+ virtual bool
+ more ();
+
+ virtual const char*
+ peek ();
+
+ virtual const char*
+ next ();
+
+ virtual void
+ skip ();
+
+ private:
+ int i_;
+ int& argc_;
+ char** argv_;
+ bool erase_;
+ };
+
+ class argv_file_scanner: public argv_scanner
+ {
+ public:
+ argv_file_scanner (int& argc,
+ char** argv,
+ const std::string& option,
+ bool erase = false);
+
+ argv_file_scanner (int start,
+ int& argc,
+ char** argv,
+ const std::string& option,
+ bool erase = false);
+
+ struct option_info
+ {
+ // If search_func is not NULL, it is called, with the arg
+ // value as the second argument, to locate the options file.
+ // If it returns an empty string, then the file is ignored.
+ //
+ const char* option;
+ std::string (*search_func) (const char*, void* arg);
+ void* arg;
+ };
+
+ argv_file_scanner (int& argc,
+ char** argv,
+ const option_info* options,
+ std::size_t options_count,
+ bool erase = false);
+
+ argv_file_scanner (int start,
+ int& argc,
+ char** argv,
+ const option_info* options,
+ std::size_t options_count,
+ bool erase = false);
+
+ virtual bool
+ more ();
+
+ virtual const char*
+ peek ();
+
+ virtual const char*
+ next ();
+
+ virtual void
+ skip ();
+
+ private:
+ const option_info*
+ find (const char*) const;
+
+ void
+ load (const std::string& file);
+
+ typedef argv_scanner base;
+
+ const std::string option_;
+ option_info option_info_;
+ const option_info* options_;
+ std::size_t options_count_;
+
+ std::string hold_;
+ std::deque<std::string> args_;
+ bool skip_;
+ };
+
+ template <typename X>
+ struct parser;
+}
+
+#include <cstddef>
+
+#include <types.hxx>
+
+class help_options
+{
+ public:
+ help_options (int& argc,
+ char** argv,
+ bool erase = false,
+ ::cli::unknown_mode option = ::cli::unknown_mode::fail,
+ ::cli::unknown_mode argument = ::cli::unknown_mode::stop);
+
+ help_options (int start,
+ int& argc,
+ char** argv,
+ bool erase = false,
+ ::cli::unknown_mode option = ::cli::unknown_mode::fail,
+ ::cli::unknown_mode argument = ::cli::unknown_mode::stop);
+
+ help_options (int& argc,
+ char** argv,
+ int& end,
+ bool erase = false,
+ ::cli::unknown_mode option = ::cli::unknown_mode::fail,
+ ::cli::unknown_mode argument = ::cli::unknown_mode::stop);
+
+ help_options (int start,
+ int& argc,
+ char** argv,
+ int& end,
+ bool erase = false,
+ ::cli::unknown_mode option = ::cli::unknown_mode::fail,
+ ::cli::unknown_mode argument = ::cli::unknown_mode::stop);
+
+ help_options (::cli::scanner&,
+ ::cli::unknown_mode option = ::cli::unknown_mode::fail,
+ ::cli::unknown_mode argument = ::cli::unknown_mode::stop);
+
+ help_options ();
+
+ // Option accessors.
+ //
+ const bool&
+ help () const;
+
+ const bool&
+ version () const;
+
+ const bool&
+ proprietary_license () const;
+
+ // Print usage information.
+ //
+ static void
+ print_usage (::std::wostream&);
+
+ // Implementation details.
+ //
+ protected:
+ bool
+ _parse (const char*, ::cli::scanner&);
+
+ private:
+ void
+ _parse (::cli::scanner&,
+ ::cli::unknown_mode option,
+ ::cli::unknown_mode argument);
+
+ public:
+ bool help_;
+ bool version_;
+ bool proprietary_license_;
+};
+
+class options
+{
+ public:
+ // Option accessors.
+ //
+ const NarrowStrings&
+ disable_warning () const;
+
+ bool
+ disable_warning_specified () const;
+
+ const std::string&
+ options_file () const;
+
+ bool
+ options_file_specified () const;
+
+ const bool&
+ show_sloc () const;
+
+ const std::size_t&
+ sloc_limit () const;
+
+ bool
+ sloc_limit_specified () const;
+
+ const bool&
+ proprietary_license () const;
+
+ const NarrowString&
+ custom_literals () const;
+
+ bool
+ custom_literals_specified () const;
+
+ const bool&
+ preserve_anonymous () const;
+
+ const bool&
+ show_anonymous () const;
+
+ const NarrowStrings&
+ anonymous_regex () const;
+
+ bool
+ anonymous_regex_specified () const;
+
+ const bool&
+ anonymous_regex_trace () const;
+
+ const bool&
+ morph_anonymous () const;
+
+ const NarrowStrings&
+ location_map () const;
+
+ bool
+ location_map_specified () const;
+
+ const NarrowStrings&
+ location_regex () const;
+
+ bool
+ location_regex_specified () const;
+
+ const bool&
+ location_regex_trace () const;
+
+ const bool&
+ file_per_type () const;
+
+ const NarrowStrings&
+ type_file_regex () const;
+
+ bool
+ type_file_regex_specified () const;
+
+ const bool&
+ type_file_regex_trace () const;
+
+ const NarrowStrings&
+ schema_file_regex () const;
+
+ bool
+ schema_file_regex_specified () const;
+
+ const bool&
+ schema_file_regex_trace () const;
+
+ const bool&
+ fat_type_file () const;
+
+ const NarrowString&
+ file_list () const;
+
+ bool
+ file_list_specified () const;
+
+ const NarrowString&
+ file_list_prologue () const;
+
+ bool
+ file_list_prologue_specified () const;
+
+ const NarrowString&
+ file_list_epilogue () const;
+
+ bool
+ file_list_epilogue_specified () const;
+
+ const NarrowString&
+ file_list_delim () const;
+
+ bool
+ file_list_delim_specified () const;
+
+ const bool&
+ disable_multi_import () const;
+
+ const bool&
+ disable_full_check () const;
+
+ // Print usage information.
+ //
+ static void
+ print_usage (::std::wostream&);
+
+ // Implementation details.
+ //
+ protected:
+ options ();
+
+ bool
+ _parse (const char*, ::cli::scanner&);
+
+ public:
+ NarrowStrings disable_warning_;
+ bool disable_warning_specified_;
+ std::string options_file_;
+ bool options_file_specified_;
+ bool show_sloc_;
+ std::size_t sloc_limit_;
+ bool sloc_limit_specified_;
+ bool proprietary_license_;
+ NarrowString custom_literals_;
+ bool custom_literals_specified_;
+ bool preserve_anonymous_;
+ bool show_anonymous_;
+ NarrowStrings anonymous_regex_;
+ bool anonymous_regex_specified_;
+ bool anonymous_regex_trace_;
+ bool morph_anonymous_;
+ NarrowStrings location_map_;
+ bool location_map_specified_;
+ NarrowStrings location_regex_;
+ bool location_regex_specified_;
+ bool location_regex_trace_;
+ bool file_per_type_;
+ NarrowStrings type_file_regex_;
+ bool type_file_regex_specified_;
+ bool type_file_regex_trace_;
+ NarrowStrings schema_file_regex_;
+ bool schema_file_regex_specified_;
+ bool schema_file_regex_trace_;
+ bool fat_type_file_;
+ NarrowString file_list_;
+ bool file_list_specified_;
+ NarrowString file_list_prologue_;
+ bool file_list_prologue_specified_;
+ NarrowString file_list_epilogue_;
+ bool file_list_epilogue_specified_;
+ NarrowString file_list_delim_;
+ bool file_list_delim_specified_;
+ bool disable_multi_import_;
+ bool disable_full_check_;
+};
+
+#include <options.ixx>
+
+// Begin epilogue.
+//
+//
+// End epilogue.
+
+#endif // OPTIONS_HXX
diff --git a/xsd/xsd/options.ixx b/xsd/xsd/options.ixx
new file mode 100644
index 0000000..f30c651
--- /dev/null
+++ b/xsd/xsd/options.ixx
@@ -0,0 +1,462 @@
+// This code was generated by CLI, a command line interface
+// compiler for C++.
+//
+
+// Begin prologue.
+//
+//
+// End prologue.
+
+namespace cli
+{
+ // unknown_mode
+ //
+ inline unknown_mode::
+ unknown_mode (value v)
+ : v_ (v)
+ {
+ }
+
+ // exception
+ //
+ inline ::std::wostream&
+ operator<< (::std::wostream& os, const exception& e)
+ {
+ e.print (os);
+ return os;
+ }
+
+ // unknown_option
+ //
+ inline unknown_option::
+ unknown_option (const std::string& option)
+ : option_ (option)
+ {
+ }
+
+ inline const std::string& unknown_option::
+ option () const
+ {
+ return option_;
+ }
+
+ // unknown_argument
+ //
+ inline unknown_argument::
+ unknown_argument (const std::string& argument)
+ : argument_ (argument)
+ {
+ }
+
+ inline const std::string& unknown_argument::
+ argument () const
+ {
+ return argument_;
+ }
+
+ // missing_value
+ //
+ inline missing_value::
+ missing_value (const std::string& option)
+ : option_ (option)
+ {
+ }
+
+ inline const std::string& missing_value::
+ option () const
+ {
+ return option_;
+ }
+
+ // invalid_value
+ //
+ inline invalid_value::
+ invalid_value (const std::string& option,
+ const std::string& value)
+ : option_ (option), value_ (value)
+ {
+ }
+
+ inline const std::string& invalid_value::
+ option () const
+ {
+ return option_;
+ }
+
+ inline const std::string& invalid_value::
+ value () const
+ {
+ return value_;
+ }
+
+ // file_io_failure
+ //
+ inline file_io_failure::
+ file_io_failure (const std::string& file)
+ : file_ (file)
+ {
+ }
+
+ inline const std::string& file_io_failure::
+ file () const
+ {
+ return file_;
+ }
+
+ // unmatched_quote
+ //
+ inline unmatched_quote::
+ unmatched_quote (const std::string& argument)
+ : argument_ (argument)
+ {
+ }
+
+ inline const std::string& unmatched_quote::
+ argument () const
+ {
+ return argument_;
+ }
+
+ // argv_scanner
+ //
+ inline argv_scanner::
+ argv_scanner (int& argc, char** argv, bool erase)
+ : i_ (1), argc_ (argc), argv_ (argv), erase_ (erase)
+ {
+ }
+
+ inline argv_scanner::
+ argv_scanner (int start, int& argc, char** argv, bool erase)
+ : i_ (start), argc_ (argc), argv_ (argv), erase_ (erase)
+ {
+ }
+
+ inline int argv_scanner::
+ end () const
+ {
+ return i_;
+ }
+
+ // argv_file_scanner
+ //
+ inline argv_file_scanner::
+ argv_file_scanner (int& argc,
+ char** argv,
+ const std::string& option,
+ bool erase)
+ : argv_scanner (argc, argv, erase),
+ option_ (option),
+ options_ (&option_info_),
+ options_count_ (1),
+ skip_ (false)
+ {
+ option_info_.option = option_.c_str ();
+ option_info_.search_func = 0;
+ }
+
+ inline argv_file_scanner::
+ argv_file_scanner (int start,
+ int& argc,
+ char** argv,
+ const std::string& option,
+ bool erase)
+ : argv_scanner (start, argc, argv, erase),
+ option_ (option),
+ options_ (&option_info_),
+ options_count_ (1),
+ skip_ (false)
+ {
+ option_info_.option = option_.c_str ();
+ option_info_.search_func = 0;
+ }
+
+ inline argv_file_scanner::
+ argv_file_scanner (int& argc,
+ char** argv,
+ const option_info* options,
+ std::size_t options_count,
+ bool erase)
+ : argv_scanner (argc, argv, erase),
+ options_ (options),
+ options_count_ (options_count),
+ skip_ (false)
+ {
+ }
+
+ inline argv_file_scanner::
+ argv_file_scanner (int start,
+ int& argc,
+ char** argv,
+ const option_info* options,
+ std::size_t options_count,
+ bool erase)
+ : argv_scanner (start, argc, argv, erase),
+ options_ (options),
+ options_count_ (options_count),
+ skip_ (false)
+ {
+ }
+}
+
+// help_options
+//
+
+inline const bool& help_options::
+help () const
+{
+ return this->help_;
+}
+
+inline const bool& help_options::
+version () const
+{
+ return this->version_;
+}
+
+inline const bool& help_options::
+proprietary_license () const
+{
+ return this->proprietary_license_;
+}
+
+// options
+//
+
+inline const NarrowStrings& options::
+disable_warning () const
+{
+ return this->disable_warning_;
+}
+
+inline bool options::
+disable_warning_specified () const
+{
+ return this->disable_warning_specified_;
+}
+
+inline const std::string& options::
+options_file () const
+{
+ return this->options_file_;
+}
+
+inline bool options::
+options_file_specified () const
+{
+ return this->options_file_specified_;
+}
+
+inline const bool& options::
+show_sloc () const
+{
+ return this->show_sloc_;
+}
+
+inline const std::size_t& options::
+sloc_limit () const
+{
+ return this->sloc_limit_;
+}
+
+inline bool options::
+sloc_limit_specified () const
+{
+ return this->sloc_limit_specified_;
+}
+
+inline const bool& options::
+proprietary_license () const
+{
+ return this->proprietary_license_;
+}
+
+inline const NarrowString& options::
+custom_literals () const
+{
+ return this->custom_literals_;
+}
+
+inline bool options::
+custom_literals_specified () const
+{
+ return this->custom_literals_specified_;
+}
+
+inline const bool& options::
+preserve_anonymous () const
+{
+ return this->preserve_anonymous_;
+}
+
+inline const bool& options::
+show_anonymous () const
+{
+ return this->show_anonymous_;
+}
+
+inline const NarrowStrings& options::
+anonymous_regex () const
+{
+ return this->anonymous_regex_;
+}
+
+inline bool options::
+anonymous_regex_specified () const
+{
+ return this->anonymous_regex_specified_;
+}
+
+inline const bool& options::
+anonymous_regex_trace () const
+{
+ return this->anonymous_regex_trace_;
+}
+
+inline const bool& options::
+morph_anonymous () const
+{
+ return this->morph_anonymous_;
+}
+
+inline const NarrowStrings& options::
+location_map () const
+{
+ return this->location_map_;
+}
+
+inline bool options::
+location_map_specified () const
+{
+ return this->location_map_specified_;
+}
+
+inline const NarrowStrings& options::
+location_regex () const
+{
+ return this->location_regex_;
+}
+
+inline bool options::
+location_regex_specified () const
+{
+ return this->location_regex_specified_;
+}
+
+inline const bool& options::
+location_regex_trace () const
+{
+ return this->location_regex_trace_;
+}
+
+inline const bool& options::
+file_per_type () const
+{
+ return this->file_per_type_;
+}
+
+inline const NarrowStrings& options::
+type_file_regex () const
+{
+ return this->type_file_regex_;
+}
+
+inline bool options::
+type_file_regex_specified () const
+{
+ return this->type_file_regex_specified_;
+}
+
+inline const bool& options::
+type_file_regex_trace () const
+{
+ return this->type_file_regex_trace_;
+}
+
+inline const NarrowStrings& options::
+schema_file_regex () const
+{
+ return this->schema_file_regex_;
+}
+
+inline bool options::
+schema_file_regex_specified () const
+{
+ return this->schema_file_regex_specified_;
+}
+
+inline const bool& options::
+schema_file_regex_trace () const
+{
+ return this->schema_file_regex_trace_;
+}
+
+inline const bool& options::
+fat_type_file () const
+{
+ return this->fat_type_file_;
+}
+
+inline const NarrowString& options::
+file_list () const
+{
+ return this->file_list_;
+}
+
+inline bool options::
+file_list_specified () const
+{
+ return this->file_list_specified_;
+}
+
+inline const NarrowString& options::
+file_list_prologue () const
+{
+ return this->file_list_prologue_;
+}
+
+inline bool options::
+file_list_prologue_specified () const
+{
+ return this->file_list_prologue_specified_;
+}
+
+inline const NarrowString& options::
+file_list_epilogue () const
+{
+ return this->file_list_epilogue_;
+}
+
+inline bool options::
+file_list_epilogue_specified () const
+{
+ return this->file_list_epilogue_specified_;
+}
+
+inline const NarrowString& options::
+file_list_delim () const
+{
+ return this->file_list_delim_;
+}
+
+inline bool options::
+file_list_delim_specified () const
+{
+ return this->file_list_delim_specified_;
+}
+
+inline const bool& options::
+disable_multi_import () const
+{
+ return this->disable_multi_import_;
+}
+
+inline const bool& options::
+disable_full_check () const
+{
+ return this->disable_full_check_;
+}
+
+// Begin epilogue.
+//
+//
+// End epilogue.
diff --git a/xsd/xsd/processing/cardinality/processor.cxx b/xsd/xsd/processing/cardinality/processor.cxx
index 473c412..f43395a 100644
--- a/xsd/xsd/processing/cardinality/processor.cxx
+++ b/xsd/xsd/processing/cardinality/processor.cxx
@@ -1,26 +1,23 @@
// file : processing/cardinality/processor.cxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2006-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2006-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
-#include <processing/cardinality/processor.hxx>
-
-#include <elements.hxx>
+#include <map>
#include <xsd-frontend/semantic-graph.hxx>
#include <xsd-frontend/traversal.hxx>
-#include <cult/containers/map.hxx>
+#include <elements.hxx>
+
+#include <processing/cardinality/processor.hxx>
+
+using namespace std;
namespace Processing
{
- using namespace Cult;
-
namespace SemanticGraph = XSDFrontend::SemanticGraph;
namespace Traversal = XSDFrontend::Traversal;
- typedef WideString String;
-
namespace Cardinality
{
namespace
@@ -39,8 +36,7 @@ namespace Processing
{
}
- ElementInfo (SemanticGraph::Element& e,
- UnsignedLong min_, UnsignedLong max_)
+ ElementInfo (SemanticGraph::Element& e, size_t min_, size_t max_)
: min (min_), max (max_), e_ (&e)
{
}
@@ -53,13 +49,13 @@ namespace Processing
}
public:
- UnsignedLong min, max;
+ size_t min, max;
private:
SemanticGraph::Element* e_;
};
- typedef Cult::Containers::Map<String, ElementInfo> ElementInfoMap;
+ typedef map<String, ElementInfo> ElementInfoMap;
//
//
@@ -75,8 +71,7 @@ namespace Processing
{
}
- AnyInfo (SemanticGraph::Any& a,
- UnsignedLong min_, UnsignedLong max_)
+ AnyInfo (SemanticGraph::Any& a, size_t min_, size_t max_)
: min (min_), max (max_), a_ (&a)
{
}
@@ -89,13 +84,13 @@ namespace Processing
}
public:
- UnsignedLong min, max;
+ size_t min, max;
private:
SemanticGraph::Any* a_;
};
- typedef Cult::Containers::Map<String, AnyInfo> AnyInfoMap;
+ typedef map<String, AnyInfo> AnyInfoMap;
//
//
@@ -105,13 +100,13 @@ namespace Processing
Traversal::Element,
Traversal::Any
{
- virtual Void
+ virtual void
traverse (SemanticGraph::All& a)
{
traverse_sequence (a);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Choice& c)
{
using SemanticGraph::Compositor;
@@ -135,20 +130,26 @@ namespace Processing
// those that are we need to choose minimum between
// the two for min and maximum for max.
//
- for (ElementInfoMap::Iterator i (el_map.begin ());
+ for (ElementInfoMap::iterator i (el_map.begin ());
i != el_map.end (); ++i)
{
String const& name (i->first);
ElementInfo& ei (i->second);
- ElementInfoMap::Iterator j (t.el_map.find (name));
+ ElementInfoMap::iterator j (t.el_map.find (name));
if (j == t.el_map.end ())
ei.min = 0;
else
{
ei.min = j->second.min < ei.min ? j->second.min : ei.min;
- ei.max = j->second.max > ei.max ? j->second.max : ei.max;
+
+ // Unbounded is encoded as 0.
+ //
+ if (j->second.max == 0 || ei.max == 0)
+ ei.max = 0;
+ else
+ ei.max = j->second.max > ei.max ? j->second.max : ei.max;
}
}
@@ -156,13 +157,13 @@ namespace Processing
// not in the map, we need to add to the map and set their
// min to 0.
//
- for (ElementInfoMap::Iterator i (t.el_map.begin ());
+ for (ElementInfoMap::iterator i (t.el_map.begin ());
i != t.el_map.end (); ++i)
{
String const& name (i->first);
ElementInfo& ei (i->second);
- ElementInfoMap::Iterator j (el_map.find (name));
+ ElementInfoMap::iterator j (el_map.find (name));
if (j == el_map.end ())
el_map[name] = ElementInfo (ei.element (), 0, ei.max);
@@ -173,7 +174,7 @@ namespace Processing
// we need to copy them from each arm of choice and set min to
// 0.
//
- for (AnyInfoMap::Iterator i (t.any_map.begin ());
+ for (AnyInfoMap::iterator i (t.any_map.begin ());
i != t.any_map.end (); ++i)
{
String const& name (i->first);
@@ -187,19 +188,19 @@ namespace Processing
// Choice's min and max.
//
- UnsignedLong cmin (c.min ()), cmax (c.max ());
+ size_t cmin (c.min ()), cmax (c.max ());
// Iterate over elements and wildcards in the maps and multiply
// their cardinality by cmin and cmax.
//
- for (ElementInfoMap::Iterator i (el_map.begin ());
+ for (ElementInfoMap::iterator i (el_map.begin ());
i != el_map.end (); ++i)
{
i->second.min *= cmin;
i->second.max *= cmax;
}
- for (AnyInfoMap::Iterator i (any_map.begin ());
+ for (AnyInfoMap::iterator i (any_map.begin ());
i != any_map.end (); ++i)
{
i->second.min *= cmin; // Not really necessary since min == 0.
@@ -207,20 +208,20 @@ namespace Processing
}
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Sequence& s)
{
traverse_sequence (s);
}
- Void
+ void
traverse_sequence (SemanticGraph::Compositor& c)
{
using SemanticGraph::Compositor;
// Sequence's min and max.
//
- UnsignedLong smin (c.min ()), smax (c.max ());
+ size_t smin (c.min ()), smax (c.max ());
// Go over all particles we contain and add them to the map.
//
@@ -232,14 +233,14 @@ namespace Processing
// Handle elements.
//
- for (ElementInfoMap::Iterator i (t.el_map.begin ());
+ for (ElementInfoMap::iterator i (t.el_map.begin ());
i != t.el_map.end (); ++i)
{
String const& name (i->first);
ElementInfo& ei (i->second);
- UnsignedLong min (ei.min * smin);
- UnsignedLong max (ei.max * smax);
- ElementInfoMap::Iterator j (el_map.find (name));
+ size_t min (ei.min * smin);
+ size_t max (ei.max * smax);
+ ElementInfoMap::iterator j (el_map.find (name));
if (j != el_map.end ())
{
@@ -255,13 +256,13 @@ namespace Processing
// Handle wildcards.
//
- for (AnyInfoMap::Iterator i (t.any_map.begin ());
+ for (AnyInfoMap::iterator i (t.any_map.begin ());
i != t.any_map.end (); ++i)
{
String const& name (i->first);
AnyInfo& ai (i->second);
- UnsignedLong min (ai.min * smin);
- UnsignedLong max (ai.max * smax);
+ size_t min (ai.min * smin);
+ size_t max (ai.max * smax);
assert (any_map.find (name) == any_map.end ());
@@ -270,7 +271,7 @@ namespace Processing
}
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Element& e)
{
SemanticGraph::ContainsParticle& cp (e.contained_particle ());
@@ -282,7 +283,7 @@ namespace Processing
el_map[name] = ElementInfo (e, cp.min (), cp.max ());
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Any& a)
{
SemanticGraph::ContainsParticle& cp (a.contained_particle ());
@@ -300,7 +301,7 @@ namespace Processing
//
struct Complex: Traversal::Complex
{
- virtual Void
+ virtual void
traverse (Type& c)
{
if (c.contains_compositor_p ())
@@ -308,21 +309,21 @@ namespace Processing
Particle t;
t.dispatch (c.contains_compositor ().compositor ());
- for (ElementInfoMap::Iterator i (t.el_map.begin ());
+ for (ElementInfoMap::iterator i (t.el_map.begin ());
i != t.el_map.end (); ++i)
{
ElementInfo& ei (i->second);
- FrontendElements::Context& ctx (ei.element ().context ());
+ SemanticGraph::Context& ctx (ei.element ().context ());
ctx.set ("min", ei.min);
ctx.set ("max", ei.max);
}
- for (AnyInfoMap::Iterator i (t.any_map.begin ());
+ for (AnyInfoMap::iterator i (t.any_map.begin ());
i != t.any_map.end (); ++i)
{
AnyInfo& ai (i->second);
- FrontendElements::Context& ctx (ai.any ().context ());
+ SemanticGraph::Context& ctx (ai.any ().context ());
ctx.set ("min", ai.min);
ctx.set ("max", ai.max);
@@ -340,13 +341,13 @@ namespace Processing
//
struct Attribute: Traversal::Attribute
{
- virtual Void
+ virtual void
traverse (Type& a)
{
- FrontendElements::Context& ctx (a.context ());
+ SemanticGraph::Context& ctx (a.context ());
- ctx.set ("min", a.optional_p () ? 0UL : 1UL);
- ctx.set ("max", 1UL);
+ ctx.set ("min", size_t (a.optional_p () ? 0 : 1));
+ ctx.set ("max", size_t (1));
}
};
@@ -355,7 +356,7 @@ namespace Processing
//
struct Uses: Traversal::Uses
{
- virtual Void
+ virtual void
traverse (Type& u)
{
SemanticGraph::Schema& s (u.schema ());
@@ -369,7 +370,7 @@ namespace Processing
};
}
- Void Processor::
+ void Processor::
process (SemanticGraph::Schema& tu, SemanticGraph::Path const&)
{
Traversal::Schema schema;
diff --git a/xsd/xsd/processing/cardinality/processor.hxx b/xsd/xsd/processing/cardinality/processor.hxx
index 31c6ef8..2b4ebe0 100644
--- a/xsd/xsd/processing/cardinality/processor.hxx
+++ b/xsd/xsd/processing/cardinality/processor.hxx
@@ -1,28 +1,25 @@
// file : processing/cardinality/processor.hxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2006-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2006-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#ifndef PROCESSING_CARDINALITY_PROCESSOR_HXX
#define PROCESSING_CARDINALITY_PROCESSOR_HXX
-#include <cult/types.hxx>
-
#include <xsd-frontend/semantic-graph/elements.hxx> // Path
#include <xsd-frontend/semantic-graph/schema.hxx>
+#include <types.hxx>
+
namespace Processing
{
namespace Cardinality
{
- using namespace Cult::Types;
-
class Processor
{
public:
struct Failed {};
- Void
+ void
process (XSDFrontend::SemanticGraph::Schema&,
XSDFrontend::SemanticGraph::Path const& file);
};
diff --git a/xsd/xsd/processing/inheritance/processor.cxx b/xsd/xsd/processing/inheritance/processor.cxx
index d92ea6c..6680a39 100644
--- a/xsd/xsd/processing/inheritance/processor.cxx
+++ b/xsd/xsd/processing/inheritance/processor.cxx
@@ -1,8 +1,10 @@
// file : processing/inheritance/processor.cxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2006-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2006-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+#include <set>
+#include <iostream>
+
#include <processing/inheritance/processor.hxx>
#include <elements.hxx>
@@ -10,21 +12,13 @@
#include <xsd-frontend/semantic-graph.hxx>
#include <xsd-frontend/traversal.hxx>
-#include <cult/containers/set.hxx>
-
-#include <iostream>
-using std::wcerr;
-using std::endl;
+using namespace std;
namespace Processing
{
- using namespace Cult;
-
namespace SemanticGraph = XSDFrontend::SemanticGraph;
namespace Traversal = XSDFrontend::Traversal;
- typedef WideString String;
-
namespace Inheritance
{
namespace
@@ -43,15 +37,14 @@ namespace Processing
String member_xpath;
};
- inline Boolean
+ inline bool
operator< (Dep const& a, Dep const& b)
{
return &a.type < &b.type;
}
- typedef Containers::Set<Dep> DepSet;
- typedef Containers::Set<SemanticGraph::Type*> TypeSet;
-
+ typedef set<Dep> DepSet;
+ typedef set<SemanticGraph::Type*> TypeSet;
String
xpath (SemanticGraph::Nameable& n)
@@ -88,7 +81,7 @@ namespace Processing
*this >> names_ >> *this;
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Complex& c)
{
using SemanticGraph::Complex;
@@ -103,14 +96,14 @@ namespace Processing
names (c);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Member& m)
{
SemanticGraph::Type& t (m.type ());
if (!t.named_p () && types_seen_.find (&t) == types_seen_.end ())
{
- FrontendElements::Context& ctx (t.context ());
+ SemanticGraph::Context& ctx (t.context ());
last_xpath_ = xpath (m);
@@ -158,14 +151,14 @@ namespace Processing
}
template <typename E>
- Void
+ void
add_edge_left (E& e)
{
node_.add_edge_left (e, arg_);
}
template <typename E>
- Void
+ void
add_edge_right (E& e)
{
node_.add_edge_right (e, arg_);
@@ -185,26 +178,26 @@ namespace Processing
{
Global (SemanticGraph::Schema& root,
SemanticGraph::Schema& schema,
- Boolean& failed)
+ bool& failed)
: root_ (root), schema_ (schema), failed_ (failed)
{
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Type& t)
{
if (t.named_p ())
types_seen_.insert (&t);
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Complex& c)
{
check_dep (c, c);
types_seen_.insert (&c);
};
- virtual Void
+ virtual void
traverse (SemanticGraph::Element& e)
{
SemanticGraph::Type& t (e.type ());
@@ -218,7 +211,7 @@ namespace Processing
};
private:
- Void
+ void
check_dep (SemanticGraph::Nameable& global,
SemanticGraph::Type& type)
{
@@ -236,12 +229,19 @@ namespace Processing
complex.dispatch (type);
}
- for (DepSet::ConstIterator i (prereqs.begin ());
+ for (DepSet::const_iterator i (prereqs.begin ());
i != prereqs.end (); ++i)
{
Dep const& dep (*i);
Type& t (dep.type);
+ // Ignore IDREF templates.
+ //
+ if (!t.named_p () &&
+ (t.is_a<SemanticGraph::Fundamental::IdRef> () ||
+ t.is_a<SemanticGraph::Fundamental::IdRefs> ()))
+ continue;
+
// We won't be able to generate compilable code in case of a
// dependency on ourselves (e.g., a member element with
// anonymous type that inherits from us).
@@ -311,7 +311,6 @@ namespace Processing
continue;
}
-
//wcerr << "type '" << t.name () << "' needs to be moved " <<
// "before " << (global.is_a<Type> () ? "type" : "element") <<
// " '" << global.name () << "'" << endl;
@@ -328,6 +327,11 @@ namespace Processing
// Insert a new Names edge before global.
//
{
+ // t.scope () and global.scope () can be different in
+ // case of the chameleon inclusion.
+ //
+ Scope& scope (global.scope ());
+
// Convert to the insert-after call.
//
Scope::NamesIterator i (scope.find (global.named ()));
@@ -353,7 +357,7 @@ namespace Processing
private:
// Return true if root sources s.
//
- Boolean
+ bool
sources_p (SemanticGraph::Schema& root, SemanticGraph::Schema& s)
{
using SemanticGraph::Schema;
@@ -376,40 +380,55 @@ namespace Processing
SemanticGraph::Schema& root_;
SemanticGraph::Schema& schema_;
TypeSet types_seen_;
- Boolean& failed_;
+ bool& failed_;
};
+ // Sources traverser that goes into each schema only once.
+ //
+ struct Sources: Traversal::Sources
+ {
+ virtual void
+ traverse (SemanticGraph::Sources& s)
+ {
+ if (schemas_.insert (&s.schema ()).second)
+ Traversal::Sources::traverse (s);
+ }
+
+ private:
+ set<SemanticGraph::Schema*> schemas_;
+ };
+
// Go into included/imported schemas while making sure we don't
// process the same stuff more than once.
//
struct Uses: Traversal::Includes, Traversal::Imports
{
- Uses (SemanticGraph::Schema& root, Boolean& failed)
+ Uses (SemanticGraph::Schema& root, bool& failed)
: root_ (root), failed_ (failed)
{
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Includes& i)
{
traverse (i.schema ());
}
- virtual Void
+ virtual void
traverse (SemanticGraph::Imports& i)
{
traverse (i.schema ());
}
private:
- Void
+ void
traverse (SemanticGraph::Schema& s)
{
if (!s.context ().count ("processing-inheritance-seen"))
{
Traversal::Schema schema;
- Traversal::Sources sources;
+ Sources sources;
schema >> sources >> schema;
schema >> *this;
@@ -431,21 +450,21 @@ namespace Processing
private:
SemanticGraph::Schema& root_;
- Boolean& failed_;
+ bool& failed_;
};
}
- Void Processor::
+ void Processor::
process (SemanticGraph::Schema& tu, SemanticGraph::Path const&)
{
- Boolean failed (false);
+ bool failed (false);
// We need to process include/imported schemas since other
// parts of the process, for example, name processors can
// rely on the order of types in the schema.
//
Traversal::Schema schema;
- Traversal::Sources sources;
+ Sources sources;
Uses uses (tu, failed);
schema >> sources >> schema;
diff --git a/xsd/xsd/processing/inheritance/processor.hxx b/xsd/xsd/processing/inheritance/processor.hxx
index aba3b49..46a33c7 100644
--- a/xsd/xsd/processing/inheritance/processor.hxx
+++ b/xsd/xsd/processing/inheritance/processor.hxx
@@ -1,28 +1,25 @@
// file : processing/inheritance/processor.hxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2006-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2006-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#ifndef PROCESSING_INHERITANCE_PROCESSOR_HXX
#define PROCESSING_INHERITANCE_PROCESSOR_HXX
-#include <cult/types.hxx>
-
#include <xsd-frontend/semantic-graph/elements.hxx> // Path
#include <xsd-frontend/semantic-graph/schema.hxx>
+#include <types.hxx>
+
namespace Processing
{
namespace Inheritance
{
- using namespace Cult::Types;
-
class Processor
{
public:
struct Failed {};
- Void
+ void
process (XSDFrontend::SemanticGraph::Schema&,
XSDFrontend::SemanticGraph::Path const& file);
};
diff --git a/xsd/xsd/type-map/lexer.cxx b/xsd/xsd/type-map/lexer.cxx
index 96e42de..fe7ecfc 100644
--- a/xsd/xsd/type-map/lexer.cxx
+++ b/xsd/xsd/type-map/lexer.cxx
@@ -1,6 +1,5 @@
// file : xsd/type-map/lexer.cxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2007-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2007-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#include <iostream>
@@ -68,7 +67,7 @@ namespace TypeMap
if (is_.eof ())
return Token (Token::eos, L"<end-of-stream>", line_);
- Boolean quote (c == '"');
+ bool quote (c == '"');
if (!quote)
lexeme += c;
diff --git a/xsd/xsd/type-map/lexer.hxx b/xsd/xsd/type-map/lexer.hxx
index 923c85f..0d3af42 100644
--- a/xsd/xsd/type-map/lexer.hxx
+++ b/xsd/xsd/type-map/lexer.hxx
@@ -1,6 +1,5 @@
// file : xsd/type-map/lexer.hxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2007-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2007-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#ifndef XSD_TYPE_MAP_LEXER_HXX
@@ -9,13 +8,10 @@
#include <locale>
#include <iosfwd>
-#include <cult/types.hxx>
+#include <types.hxx>
namespace TypeMap
{
- using namespace Cult::Types;
- typedef WideString String;
-
class Lexer
{
public:
@@ -29,7 +25,7 @@ namespace TypeMap
eos
};
- Token (Type type, String const& lexeme, UnsignedLong line)
+ Token (Type type, String const& lexeme, size_t line)
: type_ (type), lexeme_ (lexeme), line_ (line)
{
}
@@ -46,7 +42,7 @@ namespace TypeMap
return lexeme_;
}
- UnsignedLong
+ size_t
line () const
{
return line_;
@@ -55,7 +51,7 @@ namespace TypeMap
private:
Type type_;
String lexeme_;
- UnsignedLong line_;
+ size_t line_;
};
Lexer (std::istream&, String const& path);
@@ -69,12 +65,11 @@ namespace TypeMap
std::locale locale_;
std::istream& is_;
String path_;
- UnsignedLong line_;
+ size_t line_;
String held_lexeme_;
- Boolean comment_;
+ bool comment_;
};
}
#endif // XSD_TYPE_MAP_LEXER_HXX
-
diff --git a/xsd/xsd/type-map/parser.cxx b/xsd/xsd/type-map/parser.cxx
index 9f5e2b5..e391cf7 100644
--- a/xsd/xsd/type-map/parser.cxx
+++ b/xsd/xsd/type-map/parser.cxx
@@ -1,11 +1,10 @@
// file : xsd/type-map/parser.cxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2007-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2007-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#include <iostream>
-#include <backend-elements/regex.hxx>
+#include <cutl/re.hxx>
#include <type-map/parser.hxx>
@@ -14,14 +13,14 @@ using std::endl;
namespace TypeMap
{
typedef Lexer::Token Token;
- typedef BackendElements::Regex::Format<WideChar> Format;
+ typedef cutl::re::wformat Format;
Parser::Parser (Lexer& lex, String const& path)
: lex_ (lex), path_ (path), e (std::wcerr)
{
}
- Boolean Parser::
+ bool Parser::
parse (Namespaces& ns)
{
try
@@ -83,7 +82,7 @@ namespace TypeMap
return true;
}
- Boolean Parser::
+ bool Parser::
namespace_ (Namespaces& ns)
{
// First get XML namespace.
@@ -99,7 +98,7 @@ namespace TypeMap
catch (Format const& ex)
{
e << path_ << ":" << t.line () << ": invalid namespace pattern: "
- << ex.description () << endl;
+ << ex.description ().c_str () << endl;
return false;
}
@@ -115,7 +114,7 @@ namespace TypeMap
//
t = lex_.next ();
- Boolean has_cxx_name (false);
+ bool has_cxx_name (false);
String cxx_name;
if (t.type () != Token::token)
@@ -191,7 +190,7 @@ namespace TypeMap
return true;
}
- Boolean Parser::
+ bool Parser::
include (Namespace& n)
{
Token t (lex_.next ());
@@ -222,7 +221,7 @@ namespace TypeMap
return true;
}
- Boolean Parser::
+ bool Parser::
type (Token t, Namespace& n)
{
Pattern xsd_name;
@@ -234,7 +233,7 @@ namespace TypeMap
catch (Format const& ex)
{
e << path_ << ":" << t.line () << ": invalid namespace pattern: "
- << ex.description () << endl;
+ << ex.description ().c_str () << endl;
return false;
}
diff --git a/xsd/xsd/type-map/parser.hxx b/xsd/xsd/type-map/parser.hxx
index 038d2ec..c91bb12 100644
--- a/xsd/xsd/type-map/parser.hxx
+++ b/xsd/xsd/type-map/parser.hxx
@@ -1,21 +1,17 @@
// file : xsd/type-map/parser.hxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2007-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2007-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#ifndef XSD_TYPE_MAP_PARSER_HXX
#define XSD_TYPE_MAP_PARSER_HXX
-#include <cult/types.hxx>
+#include <types.hxx>
#include <type-map/type-map.hxx>
#include <type-map/lexer.hxx>
namespace TypeMap
{
- using namespace Cult::Types;
- typedef WideString String;
-
class Parser
{
public:
@@ -23,17 +19,17 @@ namespace TypeMap
// Merge parsed namespaces.
//
- Boolean
+ bool
parse (Namespaces&);
private:
- Boolean
+ bool
namespace_ (Namespaces&);
- Boolean
+ bool
include (Namespace&);
- Boolean
+ bool
type (Lexer::Token, Namespace&);
private:
diff --git a/xsd/xsd/type-map/type-map.hxx b/xsd/xsd/type-map/type-map.hxx
index 34ceefa..cdb8a0c 100644
--- a/xsd/xsd/type-map/type-map.hxx
+++ b/xsd/xsd/type-map/type-map.hxx
@@ -1,25 +1,32 @@
// file : xsd/type-map/type-map.hxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2007-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2007-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#ifndef XSD_TYPE_MAP_TYPE_MAP_HXX
#define XSD_TYPE_MAP_TYPE_MAP_HXX
-#include <cult/types.hxx>
-#include <cult/containers/vector.hxx>
+#include <vector>
-#include <backend-elements/regex.hxx>
+#include <cutl/re.hxx>
+
+#include <types.hxx>
namespace TypeMap
{
- using namespace Cult::Types;
- typedef WideString String;
- typedef BackendElements::Regex::Pattern<WideChar> Pattern;
+ typedef cutl::re::wregex Pattern;
class Type
{
public:
+ Type (String const& xsd_name,
+ String const& cxx_ret_name,
+ String const& cxx_arg_name)
+ : xsd_name_ (xsd_name),
+ cxx_ret_name_ (cxx_ret_name),
+ cxx_arg_name_ (cxx_arg_name)
+ {
+ }
+
Type (Pattern const& xsd_name,
String const& cxx_ret_name,
String const& cxx_arg_name)
@@ -56,6 +63,11 @@ namespace TypeMap
class Namespace
{
public:
+ Namespace (String const& xsd_name)
+ : xsd_name_ (xsd_name), has_cxx_name_ (false)
+ {
+ }
+
Namespace (Pattern const& xsd_name)
: xsd_name_ (xsd_name), has_cxx_name_ (false)
{
@@ -67,7 +79,7 @@ namespace TypeMap
}
Namespace (Pattern const& xsd_name,
- Boolean has_cxx_name,
+ bool has_cxx_name,
String const& cxx_name)
: xsd_name_ (xsd_name),
has_cxx_name_ (has_cxx_name),
@@ -77,8 +89,8 @@ namespace TypeMap
//
//
- typedef Cult::Containers::Vector<String> Includes;
- typedef Includes::ConstIterator IncludesIterator;
+ typedef std::vector<String> Includes;
+ typedef Includes::const_iterator IncludesIterator;
IncludesIterator
includes_begin () const
@@ -92,7 +104,7 @@ namespace TypeMap
return includes_.end ();
}
- Void
+ void
includes_push_back (String const& i)
{
includes_.push_back (i);
@@ -100,8 +112,8 @@ namespace TypeMap
//
//
- typedef Cult::Containers::Vector<Type> Types;
- typedef Types::ConstIterator TypesIterator;
+ typedef std::vector<Type> Types;
+ typedef Types::const_iterator TypesIterator;
TypesIterator
types_begin () const
@@ -115,7 +127,15 @@ namespace TypeMap
return types_.end ();
}
- Void
+ void
+ types_push_back (String const& xsd_type,
+ String const& cxx_ret_type,
+ String const& cxx_arg_type = L"")
+ {
+ types_.push_back (Type (xsd_type, cxx_ret_type, cxx_arg_type));
+ }
+
+ void
types_push_back (Pattern const& xsd_type,
String const& cxx_ret_type,
String const& cxx_arg_type = L"")
@@ -133,7 +153,7 @@ namespace TypeMap
//
//
- Boolean
+ bool
has_cxx_name () const
{
return has_cxx_name_;
@@ -149,12 +169,11 @@ namespace TypeMap
Includes includes_;
Types types_;
Pattern xsd_name_;
- Boolean has_cxx_name_;
+ bool has_cxx_name_;
String cxx_name_;
};
- typedef Cult::Containers::Vector<Namespace> Namespaces;
+ typedef std::vector<Namespace> Namespaces;
}
#endif // XSD_TYPE_MAP_TYPE_MAP_HXX
-
diff --git a/xsd/xsd/types.hxx b/xsd/xsd/types.hxx
new file mode 100644
index 0000000..6850b42
--- /dev/null
+++ b/xsd/xsd/types.hxx
@@ -0,0 +1,20 @@
+// file : xsd/types.hxx
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#ifndef TYPES_HXX
+#define TYPES_HXX
+
+#include <vector>
+#include <cstddef> // std::size_t
+
+#include <xsd-frontend/types.hxx>
+
+using std::size_t;
+
+using XSDFrontend::String;
+using XSDFrontend::NarrowString;
+
+typedef std::vector<NarrowString> NarrowStrings;
+
+#endif // TYPES_HXX
diff --git a/xsd/xsd/usage.hxx b/xsd/xsd/usage.hxx
deleted file mode 100644
index 63ce413..0000000
--- a/xsd/xsd/usage.hxx
+++ /dev/null
@@ -1,226 +0,0 @@
-// file : xsd/usage.hxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
-// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
-
-#ifndef USAGE_HXX
-#define USAGE_HXX
-
-#include <cult/types.hxx>
-
-#include <backend-elements/indentation/buffer.hxx>
-#include <backend-elements/indentation/clip.hxx>
-
-namespace CLI
-{
- using namespace Cult::Types;
-
- template <typename C>
- class OptionsUsage: public BackendElements::Indentation::Buffer<C>
- {
- typedef BackendElements::Indentation::Buffer<C> Buffer;
-
- public:
- typedef
- typename Buffer::Traits
- Traits;
-
- typedef
- typename Buffer::AsChar
- AsChar;
-
- typedef
- typename Buffer::AsInt
- AsInt;
-
- typedef
- typename Buffer::Write
- Write;
-
- public:
- OptionsUsage (Buffer& out)
- : out_ (out),
- option_length_ (0),
- construct_ (Construct::newline)
- {
- }
-
- public:
- virtual AsInt
- put (AsChar c)
- {
- AsInt result (Traits::to_int_type (c));
-
- try
- {
- switch (c)
- {
- case '\n':
- {
- switch (construct_)
- {
- case Construct::newline:
- {
- result = out_.put (c);
- break;
- }
- case Construct::option:
- {
- construct_ = Construct::newline;
- break;
- }
- case Construct::description:
- {
- result = out_.put (c);
- construct_ = Construct::newline;
- break;
- }
- default:
- {
- abort ();
- }
- }
-
- break;
- }
- case '-':
- {
- switch (construct_)
- {
- case Construct::newline:
- {
- construct_ = Construct::option;
-
- option_length_ = 0;
-
- output_indentation ();
- result = out_.put (c);
-
- ++option_length_;
-
- break;
- }
- case Construct::option:
- {
- ++option_length_;
- //fall through
- }
- case Construct::description:
- {
- result = out_.put (c);
- break;
- }
- default:
- {
- abort ();
- }
- }
-
- break;
- }
- default:
- {
- switch (construct_)
- {
- case Construct::newline:
- {
- construct_ = Construct::description;
-
- output_indentation ();
-
- result = out_.put (c);
- break;
- }
- case Construct::option:
- {
- ++option_length_;
- //fall through
- }
- default:
- {
- result = out_.put (c);
- break;
- }
- }
-
- break;
- }
- }
- }
- catch (Write const&)
- {
- result = Traits::eof ();
- }
-
- return result;
- }
-
- virtual Void
- unbuffer ()
- {
- }
-
- private:
- Void
- output_indentation ()
- {
- UnsignedLong spaces;
-
- switch (construct_)
- {
- case Construct::option:
- {
- spaces = 2;
- option_length_ += 2;
- break;
- }
- case Construct::description:
- {
- spaces = 29;
-
- if (option_length_)
- {
- if (option_length_ > spaces)
- spaces = 1;
- else
- spaces -= option_length_;
-
- option_length_ = 0;
- }
-
- break;
- }
- default:
- {
- abort ();
- }
- }
-
- while (spaces--)
- out_.put (' ');
- }
-
- private:
- Buffer& out_;
- UnsignedLong option_length_;
-
- struct Construct
- {
- enum Value
- {
- newline,
- option,
- description
- };
- };
-
- typename Construct::Value construct_;
- };
-
- //@@ rename Indentation to Indent in be?
- //
- namespace Indent = BackendElements::Indentation;
-}
-
-#endif // USAGE_HXX
-
diff --git a/xsd/xsd/xsd.cxx b/xsd/xsd/xsd.cxx
index 2e2f6ce..f333d76 100644
--- a/xsd/xsd/xsd.cxx
+++ b/xsd/xsd/xsd.cxx
@@ -1,20 +1,17 @@
// file : xsd/xsd.cxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
-#include <cult/types.hxx>
-
-#include <cult/trace/log.hxx>
+#include <map>
+#include <vector>
+#include <memory> // std::auto_ptr
+#include <cstddef> // std::size_t
+#include <iostream>
+#include <fstream>
-#include <cult/containers/map.hxx>
-#include <cult/containers/vector.hxx>
+#include <xercesc/util/PlatformUtils.hpp>
-#include <cult/cli/exceptions.hxx>
-#include <cult/cli/file-arguments.hxx>
-#include <cult/cli/options.hxx>
-#include <cult/cli/options-spec.hxx>
-#include <cult/cli/options-parser.hxx>
+#include <cutl/re.hxx>
#include <xsd-frontend/parser.hxx>
#include <xsd-frontend/transformations/anonymous.hxx>
@@ -23,8 +20,8 @@
#include <xsd-frontend/transformations/schema-per-type.hxx>
#include <xsd-frontend/transformations/simplifier.hxx>
-#include <backend-elements/regex.hxx>
-#include <backend-elements/indentation/clip.hxx>
+#include <cxx/tree/options.hxx>
+#include <cxx/parser/options.hxx>
#include <cxx/tree/generator.hxx>
#include <cxx/parser/generator.hxx>
@@ -32,98 +29,16 @@
#include <processing/cardinality/processor.hxx>
#include <processing/inheritance/processor.hxx>
-#include <iostream>
-#include <boost/filesystem/fstream.hpp>
-
-#include <xercesc/util/PlatformUtils.hpp>
-
#include <xsd.hxx>
-#include <usage.hxx>
+#include <types.hxx>
+#include <options.hxx>
#include "../libxsd/xsd/cxx/version.hxx"
-using namespace Cult::Types;
-
-typedef Cult::Containers::Vector<NarrowString> NarrowStrings;
-
namespace SemanticGraph = XSDFrontend::SemanticGraph;
namespace Transformations = XSDFrontend::Transformations;
-using std::wcerr;
-using std::endl;
-
-namespace CLI
-{
- using namespace Cult::CLI;
-
- typedef Char const Key[];
-
- extern Key help = "help";
- extern Key version = "version";
- extern Key proprietary_license = "proprietary-license";
-
- typedef Cult::CLI::Options
- <
- help, Boolean,
- version, Boolean,
- proprietary_license, Boolean
- >
- HelpOptions;
-
- struct HelpOptionsSpec: Cult::CLI::OptionsSpec<HelpOptions> {};
-
-
- extern Key disable_warning = "disable-warning";
- extern Key sloc_limit = "sloc-limit";
- extern Key morph_anonymous = "morph-anonymous";
- extern Key preserve_anonymous = "preserve-anonymous";
- extern Key anonymous_regex = "anonymous-regex";
- extern Key anonymous_regex_trace = "anonymous-regex-trace";
- extern Key location_map = "location-map";
- extern Key location_regex = "location-regex";
- extern Key location_regex_trace = "location-regex-trace";
- extern Key custom_literals = "custom-literals";
- extern Key file_per_type = "file-per-type";
- extern Key type_file_regex = "type-file-regex";
- extern Key type_file_regex_trace = "type-file-regex-trace";
- extern Key schema_file_regex = "schema-file-regex";
- extern Key schema_file_regex_trace = "schema-file-regex-trace";
- extern Key file_list = "file-list";
- extern Key file_list_prologue = "file-list-prologue";
- extern Key file_list_epilogue = "file-list-epilogue";
- extern Key file_list_delim = "file-list-delim";
- extern Key disable_multi_import = "disable-multi-import"; // Undocumented.
- extern Key disable_full_check = "disable-full-check"; // Undocumented.
-
-
- typedef Cult::CLI::Options
- <
- disable_warning, Cult::Containers::Vector<NarrowString>,
- sloc_limit, UnsignedLong,
- morph_anonymous, Boolean,
- preserve_anonymous, Boolean,
- anonymous_regex, NarrowStrings,
- anonymous_regex_trace, Boolean,
- location_map, NarrowStrings,
- location_regex, NarrowStrings,
- location_regex_trace, Boolean,
- custom_literals, NarrowString,
- file_per_type, Boolean,
- type_file_regex, NarrowStrings,
- type_file_regex_trace, Boolean,
- schema_file_regex, NarrowStrings,
- schema_file_regex_trace, Boolean,
- file_list, NarrowString,
- file_list_prologue, NarrowString,
- file_list_epilogue, NarrowString,
- file_list_delim, NarrowString,
- disable_multi_import, Boolean,
- disable_full_check, Boolean
- >
- CommonOptions;
-
- struct CommonOptionsSpec: Cult::CLI::OptionsSpec<CommonOptions> {};
-}
+using namespace std;
//
//
@@ -133,24 +48,24 @@ struct LocationTranslator: XSDFrontend::LocationTranslator
LocationTranslator (NarrowStrings const& map,
NarrowStrings const& regex,
- Boolean trace);
+ bool trace);
virtual NarrowString
translate (NarrowString const&);
private:
- typedef Cult::Containers::Map<NarrowString, NarrowString> Map;
+ typedef map<NarrowString, NarrowString> Map;
- typedef BackendElements::Regex::Expression<Char> Regex;
- typedef BackendElements::Regex::Format<Char> RegexFormat;
- typedef Cult::Containers::Vector<Regex> RegexVector;
+ typedef cutl::re::regexsub Regex;
+ typedef cutl::re::format RegexFormat;
+ typedef vector<Regex> RegexVector;
- typedef Cult::Containers::Map<NarrowString, NarrowString> Cache;
+ typedef map<NarrowString, NarrowString> Cache;
Map map_;
RegexVector regex_;
Cache cache_;
- Boolean trace_;
+ bool trace_;
};
//
@@ -159,21 +74,21 @@ struct AnonymousNameTranslator: Transformations::AnonymousNameTranslator
{
struct Failed {};
- AnonymousNameTranslator (NarrowStrings const& regex, Boolean trace);
+ AnonymousNameTranslator (NarrowStrings const& regex, bool trace);
- virtual WideString
- translate (WideString const& file,
- WideString const& ns,
- WideString const& name,
- WideString const& xpath);
+ virtual String
+ translate (String const& file,
+ String const& ns,
+ String const& name,
+ String const& xpath);
private:
- typedef BackendElements::Regex::Expression<WideChar> Regex;
- typedef BackendElements::Regex::Format<WideChar> RegexFormat;
- typedef Cult::Containers::Vector<Regex> RegexVector;
+ typedef cutl::re::wregexsub Regex;
+ typedef cutl::re::wformat RegexFormat;
+ typedef vector<Regex> RegexVector;
RegexVector regex_;
- Boolean trace_;
+ bool trace_;
};
@@ -184,30 +99,30 @@ struct SchemaPerTypeTranslator: Transformations::SchemaPerTypeTranslator
struct Failed {};
SchemaPerTypeTranslator (NarrowStrings const& type_regex,
- Boolean type_trace,
+ bool type_trace,
NarrowStrings const& schema_regex,
- Boolean schema_trace);
+ bool schema_trace);
- virtual WideString
- translate_type (WideString const& ns, WideString const& name);
+ virtual String
+ translate_type (String const& ns, String const& name);
virtual NarrowString
translate_schema (NarrowString const& file);
private:
- typedef BackendElements::Regex::Expression<WideChar> TypeRegex;
- typedef BackendElements::Regex::Format<WideChar> TypeRegexFormat;
- typedef Cult::Containers::Vector<TypeRegex> TypeRegexVector;
+ typedef cutl::re::wregexsub TypeRegex;
+ typedef cutl::re::wformat TypeRegexFormat;
+ typedef vector<TypeRegex> TypeRegexVector;
TypeRegexVector type_regex_;
- Boolean type_trace_;
+ bool type_trace_;
- typedef BackendElements::Regex::Expression<Char> SchemaRegex;
- typedef BackendElements::Regex::Format<Char> SchemaRegexFormat;
- typedef Cult::Containers::Vector<SchemaRegex> SchemaRegexVector;
+ typedef cutl::re::regexsub SchemaRegex;
+ typedef cutl::re::format SchemaRegexFormat;
+ typedef vector<SchemaRegex> SchemaRegexVector;
SchemaRegexVector schema_regex_;
- Boolean schema_trace_;
+ bool schema_trace_;
};
//
@@ -227,57 +142,48 @@ struct XercesInitializer
// Expand the \n escape sequence.
//
-Void
+void
expand_nl (NarrowString& s);
-
-Int
-main (Int argc, Char* argv[])
+int
+main (int argc, char* argv[])
{
- std::wostream& e (wcerr);
-
- Cult::Trace::Log::instance ().level (0);
+ wostream& e (wcerr);
try
{
- CLI::FileArguments args (argc, argv, "--options-file");
-
- CLI::HelpOptions help_options (
- CLI::parse (CLI::HelpOptionsSpec (), args, CLI::UnknownMode::stop));
+ cli::argv_file_scanner args (argc, argv, "--options-file");
+ help_options help_ops (args, cli::unknown_mode::stop);
NarrowString cmd;
+ if (args.more ())
+ cmd = args.next ();
- if (args.size () > 1)
+ if (help_ops.version () || cmd == "version")
{
- cmd = args[1];
- args.erase (1);
- }
+ wostream& o (wcout);
- if (help_options.value<CLI::version> () || cmd == "version")
- {
- e << "CodeSynthesis XSD XML Schema to C++ compiler " <<
+ o << "CodeSynthesis XSD XML Schema to C++ compiler " <<
XSD_STR_VERSION << endl
- << "Copyright (C) 2005-2010 Code Synthesis Tools CC" << endl;
+ << "Copyright (c) 2005-2014 Code Synthesis Tools CC" << endl;
- if (!help_options.value<CLI::proprietary_license> () &&
- cmd == "version")
+ if (!help_ops.proprietary_license () && cmd == "version")
{
// Parse the options after the command to detect trailing
// --proprietary-license.
//
- help_options = CLI::parse (
- CLI::HelpOptionsSpec (), args, CLI::UnknownMode::stop);
+ help_ops = help_options (args, cli::unknown_mode::stop);
}
- if (help_options.value<CLI::proprietary_license> ())
+ if (help_ops.proprietary_license ())
{
- e << "The compiler was invoked in the Proprietary License mode. You "
+ o << "The compiler was invoked in the Proprietary License mode. You "
<< "should have\nreceived a proprietary license from Code Synthesis "
<< "Tools CC that entitles\nyou to use it in this mode." << endl;
}
else
{
- e << "This is free software; see the source for copying conditions. "
+ o << "This is free software; see the source for copying conditions. "
<< "There is NO\nwarranty; not even for MERCHANTABILITY or FITNESS "
<< "FOR A PARTICULAR PURPOSE." << endl;
}
@@ -285,15 +191,17 @@ main (Int argc, Char* argv[])
return 0;
}
- if (help_options.value<CLI::help> () || cmd == "help")
+ if (help_ops.help () || cmd == "help")
{
- if (cmd == "help" && args.size () > 1)
+ wostream& o (wcout);
+
+ if (cmd == "help" && args.more ())
{
- NarrowString arg (args[1]);
+ NarrowString arg (args.next ());
if (arg == "cxx-tree")
{
- e << "Usage: " << args[0] << " cxx-tree [options] file [file ...]"
+ o << "Usage: " << argv[0] << " cxx-tree [options] file [file ...]"
<< endl
<< "Options:" << endl;
@@ -301,7 +209,7 @@ main (Int argc, Char* argv[])
}
else if (arg == "cxx-parser")
{
- e << "Usage: " << args[0] << " cxx-parser [options] file [file ...]"
+ o << "Usage: " << argv[0] << " cxx-parser [options] file [file ...]"
<< endl
<< "Options:" << endl;
@@ -309,135 +217,33 @@ main (Int argc, Char* argv[])
}
else
{
- e << "error: unknown command '" << arg.c_str () << "'" << endl
- << "info: try '" << args[0] << " help' for the list of commands"
+ o << "error: unknown command '" << arg.c_str () << "'" << endl
+ << "info: try '" << argv[0] << " help' for the list of commands"
<< endl;
return 1;
}
- ::CLI::Indent::Clip< ::CLI::OptionsUsage, WideChar> clip (e);
-
- // Disable warning option.
- //
- e << "--disable-warning <warn>" << endl
- << " Disable printing warning with id <warn>. If 'all'\n"
- << " is specified for the warning id then all warnings\n"
- << " are disabled."
- << endl;
-
- // Anonymous morphing options.
- //
- e << "--preserve-anonymous" << endl
- << " Preserve anonymous types. By default anonymous\n"
- << " types are automatically named with names derived\n"
- << " from the enclosing elements/attributes."
- << endl;
-
- e << "--anonymous-regex <regex>" << endl
- << " Add the provided regular expression to the list of\n"
- << " regular expressions used to derive names for\n"
- << " anonymous types from the names of the enclosing\n"
- << " attributes/elements."
- << endl;
-
- e << "--anonymous-regex-trace" << endl
- << " Trace the process of applying regular expressions\n"
- << " specified with the --anonymous-regex option."
- << endl;
-
- // Location mapping options.
- //
- e << "--location-map <ol>=<nl>" << endl
- << " Map the original schema location <ol> that is\n"
- << " specified in the XML Schema include or import\n"
- << " elements to new schema location <nl>. Repeat\n"
- << " this option to map more than one schema location."
- << endl;
-
- e << "--location-regex <regex>" << endl
- << " Add <regex> to the list of regular expressions\n"
- << " used to map schema locations that are specified\n"
- << " in the XML Schema include or import elements."
- << endl;
-
- e << "--location-regex-trace" << endl
- << " Trace the process of applying regular expressions\n"
- << " specified with the --location-regex option."
- << endl;
-
- // File-per-type compilation mode options.
- //
- e << "--file-per-type" << endl
- << " Generate a separate set of C++ files for each\n"
- << " type defined in XML Schema."
- << endl;
-
- e << "--type-file-regex <regex>" << endl
- << " Add the provided regular expression to the list of\n"
- << " regular expressions used to translate type names\n"
- << " to file names when the --file-per-type option is\n"
- << " specified."
- << endl;
-
- e << "--type-file-regex-trace" << endl
- << " Trace the process of applying regular expressions\n"
- << " specified with the --type-file-regex option."
- << endl;
-
- e << "--schema-file-regex <regex>" << endl
- << " Add the provided regular expression to the list\n"
- << " of regular expressions used to translate schema\n"
- << " file names when the --file-per-type option is\n"
- << " specified."
- << endl;
-
- e << "--schema-file-regex-trace" << endl
- << " Trace the process of applying regular expressions\n"
- << " specified with the --schema-file-regex option."
- << endl;
-
- // File list options.
+ // Add frontend options at the end.
//
- e << "--file-list <file>" << endl
- << " Write a list of generated C++ files to <file>."
- << endl;
-
- e << "--file-list-prologue <p>" << endl
- << " Insert <p> at the beginning of the file list. All\n"
- << " occurrences of the \\n character sequence in <p>\n"
- << " are replaced with new lines."
- << endl;
-
- e << "--file-list-prologue <e>" << endl
- << " Insert <e> at the end of the file list. All\n"
- << " occurrences of the \\n character sequence in <e>\n"
- << " are replaced with new lines."
- << endl;
-
- e << "--file-list-delim <d>" << endl
- << " Delimit file names written to the file list with\n"
- << " <d> instead of new lines. All occurrences of the\n"
- << " \\n character sequence in <d> are replaced with\n"
- << " new lines."
- << endl;
+ options::print_usage (o);
}
else
{
- e << "Usage: " << args[0] << " <cmd> ..." << endl
+ o << "Usage: " << argv[0] << " <cmd> ..." << endl
<< "Commands:" << endl;
- e << " help Print usage information and exit. Use\n"
+ o << " help Print usage information and exit. Use\n"
<< " 'help <cmd>' for command-specific options."
<< endl;
- e << " version Print version and exit."
+ o << " version Print version and exit."
<< endl;
- e << " cxx-tree Generate the C++/Tree mapping."
+ o << " cxx-tree Generate the C++/Tree mapping."
<< endl;
- e << " cxx-parser Generate the C++/Parser mapping."
+ o << " cxx-parser Generate the C++/Parser mapping."
<< endl;
}
@@ -447,7 +253,7 @@ main (Int argc, Char* argv[])
if (cmd.empty ())
{
e << "error: no command specified" << endl
- << "info: try '" << args[0] << " help' for usage information" << endl;
+ << "info: try '" << argv[0] << " help' for usage information" << endl;
return 1;
}
@@ -455,7 +261,7 @@ main (Int argc, Char* argv[])
if (cmd != "cxx-tree" && cmd != "cxx-parser")
{
e << "error: unknown command '" << cmd.c_str () << "'" << endl
- << "info: try '" << args[0] << " help' for the list of commands"
+ << "info: try '" << argv[0] << " help' for the list of commands"
<< endl;
return 1;
@@ -464,81 +270,57 @@ main (Int argc, Char* argv[])
// We need to parse command line options before we can get to
// the arguments.
//
- CLI::CommonOptionsSpec common_spec;
- common_spec.option<CLI::file_list_delim> ().default_value ("\n");
+ auto_ptr<CXX::Tree::options> tree_ops (
+ cmd == "cxx-tree" ? new CXX::Tree::options (args) : 0);
+
+ auto_ptr<CXX::Parser::options> parser_ops (
+ cmd == "cxx-parser" ? new CXX::Parser::options (args) : 0);
- CLI::CommonOptions common_ops (
- CLI::parse (
- common_spec,
- args,
- CLI::UnknownMode::skip,
- CLI::UnknownMode::skip));
+ CXX::options& common_ops (
+ cmd == "cxx-tree"
+ ? static_cast<CXX::options&> (*tree_ops)
+ : static_cast<CXX::options&> (*parser_ops));
+ // Disabled warnings.
+ //
WarningSet disabled_w;
{
- typedef Cult::Containers::Vector<NarrowString> Warnings;
- Warnings const& w (common_ops.value<CLI::disable_warning> ());
+ NarrowStrings const& w (common_ops.disable_warning ());
- for (Warnings::ConstIterator i (w.begin ()); i != w.end (); ++i)
+ for (NarrowStrings::const_iterator i (w.begin ()); i != w.end (); ++i)
disabled_w.insert (*i);
}
- Boolean disabled_w_all (disabled_w.find ("all") != disabled_w.end ());
+ bool disabled_w_all (disabled_w.find ("all") != disabled_w.end ());
- if (common_ops.value<CLI::morph_anonymous> () &&
- !disabled_w_all && disabled_w.find ("D001") == disabled_w.end ())
+ if (common_ops.morph_anonymous () &&
+ !disabled_w_all &&
+ disabled_w.find ("D001") == disabled_w.end ())
{
e << "warning D001: the --morph-anonymous option is on by default and "
<< "no longer required"
<< endl;
}
- Evptr<CXX::Tree::CLI::Options> tree_ops;
- Evptr<CXX::Parser::CLI::Options> parser_ops;
-
- Boolean show_sloc (false);
-
- if (cmd == "cxx-tree")
- {
- tree_ops = new CXX::Tree::CLI::Options (
- CLI::parse (CXX::Tree::Generator::options_spec (), args));
-
- tree_ops->value<CXX::Tree::CLI::disable_multi_import> () =
- common_ops.value<CLI::disable_multi_import> ();
-
- show_sloc = tree_ops->value<CXX::Tree::CLI::show_sloc> ();
- }
- else if (cmd == "cxx-parser")
- {
- parser_ops = new CXX::Parser::CLI::Options (
- CLI::parse (CXX::Parser::Generator::options_spec (), args));
-
- show_sloc = parser_ops->value<CXX::Parser::CLI::show_sloc> ();
- }
+ // Collect all the files to compile in a vector.
+ //
+ NarrowStrings files;
+ while (args.more ())
+ files.push_back (args.next ());
- if (args.size () < 2)
+ if (files.empty ())
{
e << "error: no input file specified" << endl;
return 1;
}
- Boolean fpt (common_ops.value<CLI::file_per_type> ());
+ bool fpt (common_ops.file_per_type ());
if (cmd == "cxx-tree" || cmd == "cxx-parser")
{
- Boolean gen (false), use (false);
-
- if (cmd == "cxx-tree")
- {
- gen = tree_ops->value<CXX::Tree::CLI::generate_xml_schema> ();
- use = tree_ops->value<CXX::Tree::CLI::extern_xml_schema> ();
- }
- else if (cmd == "cxx-parser")
- {
- gen = parser_ops->value<CXX::Parser::CLI::generate_xml_schema> ();
- use = parser_ops->value<CXX::Parser::CLI::extern_xml_schema> ();
- }
+ bool gen (common_ops.generate_xml_schema ());
+ bool use (common_ops.extern_xml_schema ());
// Things get complicated when we are compiling several schemas at
// once (non-file-per-type mode) and use the --generate-xml-schema/
@@ -549,7 +331,7 @@ main (Int argc, Char* argv[])
//
if (!fpt)
{
- if (args.size () > 2 && gen && !use)
+ if (files.size () > 1 && gen && !use)
{
e << "error: --extern-xml-schema is required when compiling more "
<< "than one schema and --generate-xml-schema is specified"
@@ -558,7 +340,7 @@ main (Int argc, Char* argv[])
return 1;
}
- if (args.size () == 2 && gen && use)
+ if (files.size () == 1 && gen && use)
{
e << "error: --generate-xml-schema and --extern-xml-schema are "
<< "mutually exclusive when compiling a single schema" << endl;
@@ -596,22 +378,22 @@ main (Int argc, Char* argv[])
//
FileList file_list;
AutoUnlinks unlinks;
- UnsignedLong sloc (0);
+ size_t sloc (0);
LocationTranslator loc_translator (
- common_ops.value<CLI::location_map> (),
- common_ops.value<CLI::location_regex> (),
- common_ops.value<CLI::location_regex_trace> ());
+ common_ops.location_map (),
+ common_ops.location_regex (),
+ common_ops.location_regex_trace ());
AnonymousNameTranslator anon_translator (
- common_ops.value<CLI::anonymous_regex> (),
- common_ops.value<CLI::anonymous_regex_trace> ());
+ common_ops.anonymous_regex (),
+ common_ops.anonymous_regex_trace ());
// Load custom string literals, if any.
//
CXX::StringLiteralMap string_literal_map;
- if (NarrowString file = common_ops.value<CLI::custom_literals> ())
+ if (NarrowString file = common_ops.custom_literals ())
{
XercesInitializer xerces_init;
@@ -628,7 +410,7 @@ main (Int argc, Char* argv[])
// File-per-schema compilation mode.
//
- for (Size i (1); i < args.size (); ++i)
+ for (size_t i (0); i < files.size (); ++i)
{
// Parse schema.
//
@@ -636,15 +418,11 @@ main (Int argc, Char* argv[])
try
{
-#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2
- tu = SemanticGraph::Path (args[i], boost::filesystem::native);
-#else
- tu = SemanticGraph::Path (args[i]);
-#endif
+ tu = SemanticGraph::Path (files[i]);
}
catch (SemanticGraph::InvalidPath const&)
{
- e << "error: '" << args[i] << "' is not a valid "
+ e << "error: '" << files[i].c_str () << "' is not a valid "
<< "filesystem path" << endl;
return 1;
@@ -652,12 +430,12 @@ main (Int argc, Char* argv[])
XSDFrontend::Parser parser (
cmd != "cxx-tree",
- !common_ops.value<CLI::disable_multi_import> (),
- !common_ops.value<CLI::disable_full_check> (),
+ !common_ops.disable_multi_import (),
+ !common_ops.disable_full_check (),
loc_translator,
disabled_w);
- Evptr<SemanticGraph::Schema> schema;
+ auto_ptr<SemanticGraph::Schema> schema;
if (cmd == "cxx-tree" || cmd == "cxx-parser")
{
@@ -667,44 +445,14 @@ main (Int argc, Char* argv[])
// will need to rely on the presence of the --extern-xml-schema
// to tell us which (fake) schema file corresponds to XML Schema.
//
- Boolean gen_xml_schema (false);
+ bool gen_xml_schema (common_ops.generate_xml_schema ());
- if (cmd == "cxx-tree")
- {
- gen_xml_schema =
- tree_ops->value<CXX::Tree::CLI::generate_xml_schema> ();
-
- if (gen_xml_schema)
- {
- if (NarrowString name =
- tree_ops->value<CXX::Tree::CLI::extern_xml_schema> ())
- {
-#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2
- if (tu.native_file_string () != name)
-#else
- if (tu.string () != name)
-#endif
- gen_xml_schema = false;
- }
- }
- }
- else if (cmd == "cxx-parser")
+ if (gen_xml_schema)
{
- gen_xml_schema =
- parser_ops->value<CXX::Parser::CLI::generate_xml_schema> ();
-
- if (gen_xml_schema)
+ if (NarrowString name = common_ops.extern_xml_schema ())
{
- if (NarrowString name =
- parser_ops->value<CXX::Parser::CLI::extern_xml_schema> ())
- {
-#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2
- if (tu.native_file_string () != name)
-#else
- if (tu.string () != name)
-#endif
- gen_xml_schema = false;
- }
+ if (tu.string () != name)
+ gen_xml_schema = false;
}
}
@@ -718,7 +466,7 @@ main (Int argc, Char* argv[])
// Morph anonymous types.
//
- if (!common_ops.value<CLI::preserve_anonymous> ())
+ if (!common_ops.preserve_anonymous ())
{
try
{
@@ -835,21 +583,15 @@ main (Int argc, Char* argv[])
//
SemanticGraph::Paths paths;
- for (Size i (1); i < args.size (); ++i)
+ for (size_t i (0); i < files.size (); ++i)
{
try
{
-#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2
- paths.push_back (
- SemanticGraph::Path (args[i], boost::filesystem::native));
-#else
- paths.push_back (
- SemanticGraph::Path (args[i]));
-#endif
+ paths.push_back (SemanticGraph::Path (files[i]));
}
catch (SemanticGraph::InvalidPath const&)
{
- e << "error: '" << args[i] << "' is not a valid "
+ e << "error: '" << files[i].c_str () << "' is not a valid "
<< "filesystem path" << endl;
return 1;
@@ -858,7 +600,7 @@ main (Int argc, Char* argv[])
if (cmd == "cxx-parser" &&
paths.size () > 1 &&
- parser_ops->value<CXX::Parser::CLI::generate_test_driver> ())
+ parser_ops->generate_test_driver ())
{
e << "info: generating test driver for the first schema only: '" <<
paths[0] << "'" << endl;
@@ -866,21 +608,21 @@ main (Int argc, Char* argv[])
XSDFrontend::Parser parser (
cmd != "cxx-tree",
- !common_ops.value<CLI::disable_multi_import> (),
- !common_ops.value<CLI::disable_full_check> (),
+ !common_ops.disable_multi_import (),
+ !common_ops.disable_full_check (),
loc_translator,
disabled_w);
- Evptr<SemanticGraph::Schema> schema (parser.parse (paths));
+ auto_ptr<SemanticGraph::Schema> schema (parser.parse (paths));
// Morph anonymous types.
//
- if (!common_ops.value<CLI::preserve_anonymous> ())
+ if (!common_ops.preserve_anonymous ())
{
try
{
Transformations::Anonymous trans (anon_translator);
- trans.transform (*schema, "", false);
+ trans.transform (*schema, SemanticGraph::Path (), false);
}
catch (Transformations::Anonymous::Failed const&)
{
@@ -893,7 +635,7 @@ main (Int argc, Char* argv[])
if (cmd == "cxx-tree")
{
Transformations::EnumSynthesis trans;
- trans.transform (*schema, "");
+ trans.transform (*schema, SemanticGraph::Path ());
}
// Simplify the schema graph.
@@ -901,7 +643,7 @@ main (Int argc, Char* argv[])
if (cmd == "cxx-parser")
{
Transformations::Simplifier trans;
- trans.transform (*schema, "");
+ trans.transform (*schema, SemanticGraph::Path ());
}
// Normalize and annotate complex content restrictions.
@@ -911,7 +653,7 @@ main (Int argc, Char* argv[])
try
{
Transformations::Restriction trans;
- trans.transform (*schema, "");
+ trans.transform (*schema, SemanticGraph::Path ());
}
catch (Transformations::Restriction::Failed const&)
{
@@ -923,26 +665,29 @@ main (Int argc, Char* argv[])
//
{
Processing::Cardinality::Processor proc;
- proc.process (*schema, "");
+ proc.process (*schema, SemanticGraph::Path ());
}
// Rearrange the graph so that each type is in a seperate
// schema file.
//
- typedef Cult::Containers::Vector<SemanticGraph::Schema*> Schemas;
+ typedef vector<SemanticGraph::Schema*> Schemas;
SchemaPerTypeTranslator type_translator (
- common_ops.value<CLI::type_file_regex> (),
- common_ops.value<CLI::type_file_regex_trace> (),
- common_ops.value<CLI::schema_file_regex> (),
- common_ops.value<CLI::schema_file_regex_trace> ());
+ common_ops.type_file_regex (),
+ common_ops.type_file_regex_trace (),
+ common_ops.schema_file_regex (),
+ common_ops.schema_file_regex_trace ());
+
+ Transformations::SchemaPerType trans (
+ type_translator,
+ common_ops.fat_type_file ());
- Transformations::SchemaPerType trans (type_translator);
Schemas schemas (trans.transform (*schema));
// Generate code.
//
- for (Schemas::Iterator b (schemas.begin ()), i (b), e (schemas.end ());
+ for (Schemas::iterator b (schemas.begin ()), i (b), e (schemas.end ());
i != e; ++i)
{
SemanticGraph::Schema& s (**i);
@@ -1001,24 +746,16 @@ main (Int argc, Char* argv[])
// See if we need to produce the file list.
//
- if (NarrowString fl = common_ops.value<CLI::file_list> ())
+ if (NarrowString fl = common_ops.file_list ())
{
- typedef boost::filesystem::ofstream OutputFileStream;
+ typedef std::ofstream OutputFileStream;
try
{
OutputFileStream ofs;
-#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2
SemanticGraph::Path path (fl);
-#else
- SemanticGraph::Path path (fl.c_str());
-#endif
-#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2
- ofs.open (fl, std::ios_base::out);
-#else
- ofs.open (fl.c_str(), std::ios_base::out);
-#endif
+ ofs.open (path.string ().c_str (), ios_base::out);
if (!ofs.is_open ())
{
@@ -1026,16 +763,16 @@ main (Int argc, Char* argv[])
return 1;
}
- NarrowString d (common_ops.value<CLI::file_list_delim> ());
+ NarrowString d (common_ops.file_list_delim ());
expand_nl (d);
- if (NarrowString p = common_ops.value<CLI::file_list_prologue> ())
+ if (NarrowString p = common_ops.file_list_prologue ())
{
expand_nl (p);
ofs << p;
}
- for (FileList::Iterator i (file_list.begin ()), e (file_list.end ());
+ for (FileList::iterator i (file_list.begin ()), e (file_list.end ());
i != e;)
{
ofs << *i;
@@ -1044,7 +781,7 @@ main (Int argc, Char* argv[])
ofs << d;
}
- if (NarrowString e = common_ops.value<CLI::file_list_epilogue> ())
+ if (NarrowString e = common_ops.file_list_epilogue ())
{
expand_nl (e);
ofs << e;
@@ -1058,10 +795,10 @@ main (Int argc, Char* argv[])
}
}
- if (show_sloc)
+ if (common_ops.show_sloc ())
e << "total: " << sloc << endl;
- if (UnsignedLong sloc_limit = common_ops.value<CLI::sloc_limit> ())
+ if (size_t sloc_limit = common_ops.sloc_limit ())
{
if (sloc_limit < sloc)
{
@@ -1096,26 +833,10 @@ main (Int argc, Char* argv[])
{
// Diagnostic has already been issued.
}
- catch (CLI::UnexpectedOption const& e)
+ catch (cli::exception const& ex)
{
- wcerr << "error: unknown option '" << e.option ().c_str () << "'" << endl
- << "info: try '" << argv[0] << " help' for usage information"
- << endl;
- }
- catch (CLI::OptionFormat const& e)
- {
- wcerr << "error: value for option '" << e.option ().c_str ()
- << "' is invalid or missing" << endl
- << "info: try '" << argv[0] << " help' for usage information"
- << endl;
- }
- catch (CLI::OptionFile const& e)
- {
- if (e.value ())
- wcerr << "error: " << e.value ().c_str () << ": "
- << e.description ().c_str () << endl;
- else
- wcerr << "error: missing --options-file argument" << endl;
+ wcerr << ex << endl;
+ wcerr << "try '" << argv[0] << " help' for usage information" << endl;
}
return 1;
@@ -1127,16 +848,16 @@ main (Int argc, Char* argv[])
LocationTranslator::
LocationTranslator (NarrowStrings const& map,
NarrowStrings const& regex,
- Boolean trace)
+ bool trace)
: trace_ (trace)
{
// Map.
//
- for (NarrowStrings::ConstIterator i (map.begin ()); i != map.end (); ++i)
+ for (NarrowStrings::const_iterator i (map.begin ()); i != map.end (); ++i)
{
// Split the string in two parts at the last '='.
//
- Size pos (i->rfind ('='));
+ size_t pos (i->rfind ('='));
if (pos == NarrowString::npos)
{
@@ -1151,7 +872,7 @@ LocationTranslator (NarrowStrings const& map,
// Regex.
//
- for (NarrowStrings::ConstIterator i (regex.begin ()); i != regex.end (); ++i)
+ for (NarrowStrings::const_iterator i (regex.begin ()); i != regex.end (); ++i)
{
try
{
@@ -1160,7 +881,7 @@ LocationTranslator (NarrowStrings const& map,
catch (RegexFormat const& e)
{
wcerr << "error: invalid location regex: '" <<
- e.expression ().c_str () << "': " <<
+ e.regex ().c_str () << "': " <<
e.description ().c_str () << endl;
throw Failed ();
@@ -1173,14 +894,14 @@ translate (NarrowString const& l)
{
// First check the cache.
//
- Cache::ConstIterator ci (cache_.find (l));
+ Cache::const_iterator ci (cache_.find (l));
if (ci != cache_.end ())
return ci->second;
// Then check the direct map.
//
- Map::ConstIterator mi (map_.find (l));
+ Map::const_iterator mi (map_.find (l));
if (mi != map_.end ())
{
@@ -1193,15 +914,15 @@ translate (NarrowString const& l)
if (trace_)
wcerr << "location: '" << l.c_str () << "'" << endl;
- for (RegexVector::ReverseIterator i (regex_.rbegin ());
+ for (RegexVector::reverse_iterator i (regex_.rbegin ());
i != regex_.rend (); ++i)
{
if (trace_)
- wcerr << "try: '" << i->pattern () << "' : ";
+ wcerr << "try: '" << i->regex ().str ().c_str () << "' : ";
if (i->match (l))
{
- NarrowString r (i->merge (l));
+ NarrowString r (i->replace (l));
if (trace_)
wcerr << "'" << r.c_str () << "' : +" << endl;
@@ -1224,45 +945,45 @@ translate (NarrowString const& l)
//
AnonymousNameTranslator::
-AnonymousNameTranslator (NarrowStrings const& regex, Boolean trace)
+AnonymousNameTranslator (NarrowStrings const& regex, bool trace)
: trace_ (trace)
{
- for (NarrowStrings::ConstIterator i (regex.begin ()); i != regex.end (); ++i)
+ for (NarrowStrings::const_iterator i (regex.begin ()); i != regex.end (); ++i)
{
try
{
- regex_.push_back (Regex (*i));
+ regex_.push_back (Regex (String (*i)));
}
catch (RegexFormat const& e)
{
wcerr << "error: invalid anonymous type regex: '" <<
- e.expression () << "': " << e.description () << endl;
+ e.regex () << "': " << e.description ().c_str () << endl;
throw Failed ();
}
}
}
-WideString AnonymousNameTranslator::
-translate (WideString const& file,
- WideString const& ns,
- WideString const& name,
- WideString const& xpath)
+String AnonymousNameTranslator::
+translate (String const& file,
+ String const& ns,
+ String const& name,
+ String const& xpath)
{
- WideString s (file + L' ' + ns + L' ' + xpath);
+ String s (file + L' ' + ns + L' ' + xpath);
if (trace_)
wcerr << "anonymous type: '" << s << "'" << endl;
- for (RegexVector::ReverseIterator i (regex_.rbegin ());
+ for (RegexVector::reverse_iterator i (regex_.rbegin ());
i != regex_.rend (); ++i)
{
if (trace_)
- wcerr << "try: '" << i->pattern () << "' : ";
+ wcerr << "try: '" << i->regex () << "' : ";
if (i->match (s))
{
- WideString r (i->merge (s));
+ String r (i->replace (s));
if (trace_)
wcerr << "'" << r << "' : +" << endl;
@@ -1284,28 +1005,28 @@ translate (WideString const& file,
SchemaPerTypeTranslator::
SchemaPerTypeTranslator (NarrowStrings const& type_regex,
- Boolean type_trace,
+ bool type_trace,
NarrowStrings const& schema_regex,
- Boolean schema_trace)
+ bool schema_trace)
: type_trace_ (type_trace), schema_trace_ (schema_trace)
{
- for (NarrowStrings::ConstIterator i (type_regex.begin ());
+ for (NarrowStrings::const_iterator i (type_regex.begin ());
i != type_regex.end (); ++i)
{
try
{
- type_regex_.push_back (TypeRegex (*i));
+ type_regex_.push_back (TypeRegex (String (*i)));
}
catch (TypeRegexFormat const& e)
{
wcerr << "error: invalid type file regex: '" <<
- e.expression () << "': " << e.description () << endl;
+ e.regex () << "': " << e.description ().c_str () << endl;
throw Failed ();
}
}
- for (NarrowStrings::ConstIterator i (schema_regex.begin ());
+ for (NarrowStrings::const_iterator i (schema_regex.begin ());
i != schema_regex.end (); ++i)
{
try
@@ -1315,30 +1036,30 @@ SchemaPerTypeTranslator (NarrowStrings const& type_regex,
catch (SchemaRegexFormat const& e)
{
wcerr << "error: invalid type file regex: '" <<
- e.expression ().c_str () << "': " << e.description ().c_str () << endl;
+ e.regex ().c_str () << "': " << e.description ().c_str () << endl;
throw Failed ();
}
}
}
-WideString SchemaPerTypeTranslator::
-translate_type (WideString const& ns, WideString const& name)
+String SchemaPerTypeTranslator::
+translate_type (String const& ns, String const& name)
{
- WideString s (ns + L' ' + name);
+ String s (ns + L' ' + name);
if (type_trace_)
wcerr << "type: '" << s << "'" << endl;
- for (TypeRegexVector::ReverseIterator i (type_regex_.rbegin ());
+ for (TypeRegexVector::reverse_iterator i (type_regex_.rbegin ());
i != type_regex_.rend (); ++i)
{
if (type_trace_)
- wcerr << "try: '" << i->pattern () << "' : ";
+ wcerr << "try: '" << i->regex () << "' : ";
if (i->match (s))
{
- WideString r (i->merge (s));
+ String r (i->replace (s));
if (type_trace_)
wcerr << "'" << r << "' : +" << endl;
@@ -1361,15 +1082,15 @@ translate_schema (NarrowString const& file)
if (schema_trace_)
wcerr << "schema: '" << file.c_str () << "'" << endl;
- for (SchemaRegexVector::ReverseIterator i (schema_regex_.rbegin ());
+ for (SchemaRegexVector::reverse_iterator i (schema_regex_.rbegin ());
i != schema_regex_.rend (); ++i)
{
if (schema_trace_)
- wcerr << "try: '" << i->pattern () << "' : ";
+ wcerr << "try: '" << i->regex ().str ().c_str () << "' : ";
if (i->match (file))
{
- NarrowString r (i->merge (file));
+ NarrowString r (i->replace (file));
if (schema_trace_)
wcerr << "'" << r.c_str () << "' : +" << endl;
@@ -1388,10 +1109,10 @@ translate_schema (NarrowString const& file)
//
//
-Void
+void
expand_nl (NarrowString& s)
{
- for (Size i (0); i < s.size ();)
+ for (size_t i (0); i < s.size ();)
{
if (s[i] == '\\' && (i + 1) < s.size () && s[i + 1] == 'n')
{
diff --git a/xsd/xsd/xsd.hxx b/xsd/xsd/xsd.hxx
index 508c8da..8b9d6fe 100644
--- a/xsd/xsd/xsd.hxx
+++ b/xsd/xsd/xsd.hxx
@@ -1,84 +1,25 @@
// file : xsd/xsd.hxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#ifndef XSD_HXX
#define XSD_HXX
-#include <xsd-frontend/semantic-graph/elements.hxx> // Path
-
-#include <cult/types.hxx>
-#include <cult/containers/set.hxx>
-#include <cult/containers/vector.hxx>
-
-
+#include <set>
+#include <vector>
#include <cstdio> // std::remove
-using namespace Cult::Types;
-
-//
-//
-typedef Cult::Containers::Set<NarrowString> WarningSet;
+#include <cutl/shared-ptr.hxx>
+#include <cutl/fs/auto-remove.hxx>
-//
-//
-typedef Cult::Containers::Vector<NarrowString> FileList;
-
-//
-//
-struct AutoUnlink
-{
- AutoUnlink (XSDFrontend::SemanticGraph::Path const& file)
- : file_ (file), canceled_ (false)
- {
- }
-
- ~AutoUnlink ()
- {
- if (!canceled_)
- {
-#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2
- std::remove (file_.native_file_string ().c_str ());
-#else
- std::remove (file_.string ().c_str ());
-#endif
- }
- }
-
- void
- cancel ()
- {
- canceled_ = true;
- }
-
-private:
- XSDFrontend::SemanticGraph::Path file_;
- Boolean canceled_;
-};
+#include <xsd-frontend/semantic-graph/elements.hxx> // Path
-//
-//
-struct AutoUnlinks
-{
- Void
- add (XSDFrontend::SemanticGraph::Path const& file)
- {
- unlinks_.push_back (Evptr<AutoUnlink> (new AutoUnlink (file)));
- }
+#include <types.hxx>
- Void
- cancel ()
- {
- for (Unlinks::Iterator i (unlinks_.begin ()); i != unlinks_.end (); ++i)
- {
- (*i)->cancel ();
- }
- }
+typedef std::set<NarrowString> WarningSet;
+typedef std::vector<NarrowString> FileList;
-private:
- typedef Cult::Containers::Vector<Evptr<AutoUnlink> > Unlinks;
- Unlinks unlinks_;
-};
+typedef cutl::fs::auto_remove AutoUnlink;
+typedef cutl::fs::auto_removes AutoUnlinks;
#endif // XSD_HXX