diff options
Diffstat (limited to 'xsd/cxx/tree')
-rw-r--r-- | xsd/cxx/tree/cli.hxx | 2 | ||||
-rw-r--r-- | xsd/cxx/tree/counter.cxx | 2 | ||||
-rw-r--r-- | xsd/cxx/tree/elements.cxx | 3 | ||||
-rw-r--r-- | xsd/cxx/tree/elements.hxx | 1 | ||||
-rw-r--r-- | xsd/cxx/tree/generator.cxx | 73 | ||||
-rw-r--r-- | xsd/cxx/tree/generator.hxx | 2 | ||||
-rw-r--r-- | xsd/cxx/tree/name-processor.cxx | 15 | ||||
-rw-r--r-- | xsd/cxx/tree/name-processor.hxx | 9 | ||||
-rw-r--r-- | xsd/cxx/tree/tree-forward.cxx | 7 | ||||
-rw-r--r-- | xsd/cxx/tree/tree-header.cxx | 14 | ||||
-rw-r--r-- | xsd/cxx/tree/validator.cxx | 1 |
11 files changed, 106 insertions, 23 deletions
diff --git a/xsd/cxx/tree/cli.hxx b/xsd/cxx/tree/cli.hxx index 9ccf405..c9078e7 100644 --- a/xsd/cxx/tree/cli.hxx +++ b/xsd/cxx/tree/cli.hxx @@ -24,6 +24,7 @@ namespace CXX typedef Char const Key[]; extern Key char_type; + extern Key char_encoding; extern Key output_dir; extern Key generate_polymorphic; extern Key generate_serialization; @@ -119,6 +120,7 @@ namespace CXX typedef Cult::CLI::Options< char_type, NarrowString, + char_encoding, NarrowString, output_dir, NarrowString, generate_polymorphic, Boolean, generate_serialization, Boolean, diff --git a/xsd/cxx/tree/counter.cxx b/xsd/cxx/tree/counter.cxx index d8223bb..a9649b5 100644 --- a/xsd/cxx/tree/counter.cxx +++ b/xsd/cxx/tree/counter.cxx @@ -239,7 +239,7 @@ namespace CXX count (CLI::Options const& options, SemanticGraph::Schema& tu) { Counts counts; - Context ctx (std::wcerr, tu, options, counts, false, 0, 0, 0); + Context ctx (std::wcerr, tu, options, counts, false, 0, 0, 0, 0); Traversal::Schema schema; Traversal::Sources sources; diff --git a/xsd/cxx/tree/elements.cxx b/xsd/cxx/tree/elements.cxx index db1d858..444caa4 100644 --- a/xsd/cxx/tree/elements.cxx +++ b/xsd/cxx/tree/elements.cxx @@ -39,12 +39,15 @@ namespace CXX CLI::Options const& ops, Counts const& counts_, Boolean generate_xml_schema__, + StringLiteralMap const* map, Regex const* fe, Regex const* he, Regex const* ie) : CXX::Context (o, root, + 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> (), diff --git a/xsd/cxx/tree/elements.hxx b/xsd/cxx/tree/elements.hxx index 602291d..a0cb1d9 100644 --- a/xsd/cxx/tree/elements.hxx +++ b/xsd/cxx/tree/elements.hxx @@ -117,6 +117,7 @@ namespace CXX CLI::Options const& ops, Counts const& counts_, Boolean generate_xml_schema, + StringLiteralMap const*, Regex const* fwd_expr, Regex const* hxx_expr, Regex const* ixx_expr); diff --git a/xsd/cxx/tree/generator.cxx b/xsd/cxx/tree/generator.cxx index f9b055e..b81504c 100644 --- a/xsd/cxx/tree/generator.cxx +++ b/xsd/cxx/tree/generator.cxx @@ -116,6 +116,7 @@ namespace CXX 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 generate_serialization = "generate-serialization"; @@ -220,12 +221,19 @@ namespace CXX << " 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." @@ -670,6 +678,11 @@ namespace CXX << " 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; @@ -803,6 +816,7 @@ namespace CXX generate (Tree::CLI::Options const& ops, Schema& schema, Path const& file_path, + StringLiteralMap const& string_literal_map, const WarningSet& disabled_warnings, FileList& file_list, AutoUnlinks& unlinks) @@ -860,7 +874,7 @@ namespace CXX // { NameProcessor proc; - if (!proc.process (ops, schema, file_path)) + if (!proc.process (ops, schema, file_path, string_literal_map)) throw Failed (); } @@ -1179,8 +1193,15 @@ namespace CXX // if (forward) { - Context ctx (fwd, schema, ops, counts, generate_xml_schema, - &fwd_expr, &hxx_expr, &ixx_expr); + Context ctx (fwd, + schema, + ops, + counts, + generate_xml_schema, + &string_literal_map, + &fwd_expr, + &hxx_expr, + &ixx_expr); Indentation::Clip<Indentation::SLOC, WideChar> fwd_sloc (fwd); @@ -1287,8 +1308,15 @@ namespace CXX // HXX // { - Context ctx (hxx, schema, ops, counts, generate_xml_schema, - &fwd_expr, &hxx_expr, &ixx_expr); + Context ctx (hxx, + schema, + ops, + counts, + generate_xml_schema, + &string_literal_map, + &fwd_expr, + &hxx_expr, + &ixx_expr); Indentation::Clip<Indentation::SLOC, WideChar> hxx_sloc (hxx); @@ -1434,8 +1462,15 @@ namespace CXX // if (inline_) { - Context ctx (ixx, schema, ops, counts, generate_xml_schema, - &fwd_expr, &hxx_expr, &ixx_expr); + Context ctx (ixx, + schema, + ops, + counts, + generate_xml_schema, + &string_literal_map, + &fwd_expr, + &hxx_expr, + &ixx_expr); Indentation::Clip<Indentation::SLOC, WideChar> ixx_sloc (ixx); @@ -1560,8 +1595,15 @@ namespace CXX WideOutputFileStream& os (*cxx[part]); - Context ctx (os, schema, ops, counts, generate_xml_schema, - &fwd_expr, &hxx_expr, &ixx_expr); + Context ctx (os, + schema, + ops, + counts, + generate_xml_schema, + &string_literal_map, + &fwd_expr, + &hxx_expr, + &ixx_expr); Indentation::Clip<Indentation::SLOC, WideChar> cxx_sloc (os); @@ -1644,6 +1686,17 @@ namespace CXX return sloc; } + catch (UnrepresentableCharacter const& e) + { + wcerr << "error: character at position " << e.position () << " " + << "in string '" << e.string () << "' is unrepresentable in " + << "the target encoding" << endl; + + wcerr << "info: use the --custom-literals option to provide custom " + << "string literals mapping" << endl; + + throw Failed (); + } catch (NoNamespaceMapping const& e) { wcerr << e.file () << ":" << e.line () << ":" << e.column () diff --git a/xsd/cxx/tree/generator.hxx b/xsd/cxx/tree/generator.hxx index 1aa3c60..a66ede0 100644 --- a/xsd/cxx/tree/generator.hxx +++ b/xsd/cxx/tree/generator.hxx @@ -13,6 +13,7 @@ #include <xsd.hxx> +#include <cxx/literal-map.hxx> #include <cxx/tree/cli.hxx> namespace CXX @@ -36,6 +37,7 @@ namespace CXX generate (CLI::Options const& options, XSDFrontend::SemanticGraph::Schema&, XSDFrontend::SemanticGraph::Path const& file, + StringLiteralMap const&, const WarningSet& disabled_warnings, FileList& file_list, AutoUnlinks& unlinks); diff --git a/xsd/cxx/tree/name-processor.cxx b/xsd/cxx/tree/name-processor.cxx index 53027af..e15b072 100644 --- a/xsd/cxx/tree/name-processor.cxx +++ b/xsd/cxx/tree/name-processor.cxx @@ -4,7 +4,6 @@ // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #include <cxx/tree/name-processor.hxx> -#include <cxx/tree/elements.hxx> #include <backend-elements/regex.hxx> @@ -43,12 +42,14 @@ namespace CXX Counts const& counts, Boolean generate_xml_schema, SemanticGraph::Schema& root, - SemanticGraph::Path const& file) + SemanticGraph::Path const& file, + StringLiteralMap const& map) : Tree::Context (std::wcerr, root, options, counts, generate_xml_schema, + &map, 0, 0, 0), @@ -1970,12 +1971,13 @@ namespace CXX Boolean process_impl (CLI::Options const& ops, SemanticGraph::Schema& tu, - SemanticGraph::Path const& file) + SemanticGraph::Path const& file, + StringLiteralMap const& map) { try { Counts counts; - Context ctx (ops, counts, false, tu, file); + Context ctx (ops, counts, false, tu, file, map); if (tu.names_begin ()->named ().name () == L"http://www.w3.org/2001/XMLSchema") @@ -2096,9 +2098,10 @@ namespace CXX Boolean NameProcessor:: process (CLI::Options const& ops, SemanticGraph::Schema& tu, - SemanticGraph::Path const& file) + SemanticGraph::Path const& file, + StringLiteralMap const& map) { - return process_impl (ops, tu, file); + return process_impl (ops, tu, file, map); } } } diff --git a/xsd/cxx/tree/name-processor.hxx b/xsd/cxx/tree/name-processor.hxx index 9b8eac9..18c3b82 100644 --- a/xsd/cxx/tree/name-processor.hxx +++ b/xsd/cxx/tree/name-processor.hxx @@ -6,11 +6,7 @@ #ifndef CXX_TREE_NAME_PROCESSOR_HXX #define CXX_TREE_NAME_PROCESSOR_HXX -#include <cult/types.hxx> - -#include <xsd-frontend/semantic-graph.hxx> - -#include <cxx/tree/cli.hxx> +#include <cxx/tree/elements.hxx> namespace CXX { @@ -26,7 +22,8 @@ namespace CXX Boolean process (CLI::Options const&, XSDFrontend::SemanticGraph::Schema&, - XSDFrontend::SemanticGraph::Path const& file); + XSDFrontend::SemanticGraph::Path const& file, + StringLiteralMap const&); }; } } diff --git a/xsd/cxx/tree/tree-forward.cxx b/xsd/cxx/tree/tree-forward.cxx index cceedb7..02c4317 100644 --- a/xsd/cxx/tree/tree-forward.cxx +++ b/xsd/cxx/tree/tree-forward.cxx @@ -152,6 +152,13 @@ namespace CXX } else { + if (ctx.char_type == L"char" && ctx.char_encoding != L"custom") + { + ctx.os << "#include <xsd/cxx/xml/char-" << ctx.char_encoding << + ".hxx>" << endl + << endl; + } + ctx.os << "#include <xsd/cxx/tree/exceptions.hxx>" << endl << "#include <xsd/cxx/tree/elements.hxx>" << endl << "#include <xsd/cxx/tree/types.hxx>" << endl diff --git a/xsd/cxx/tree/tree-header.cxx b/xsd/cxx/tree/tree-header.cxx index 7bb630c..9b39739 100644 --- a/xsd/cxx/tree/tree-header.cxx +++ b/xsd/cxx/tree/tree-header.cxx @@ -3539,6 +3539,13 @@ namespace CXX { if (ctx.generate_xml_schema) { + if (ctx.char_type == L"char" && ctx.char_encoding != L"custom") + { + ctx.os << "#include <xsd/cxx/xml/char-" << ctx.char_encoding << + ".hxx>" << endl + << endl; + } + ctx.os << "#include <xsd/cxx/tree/exceptions.hxx>" << endl << "#include <xsd/cxx/tree/elements.hxx>" << endl << "#include <xsd/cxx/tree/types.hxx>" << endl @@ -3671,6 +3678,13 @@ namespace CXX << "#include <algorithm> // std::binary_search" << endl << endl; + if (ctx.char_type == L"char" && ctx.char_encoding != L"custom") + { + ctx.os << "#include <xsd/cxx/xml/char-" << ctx.char_encoding << + ".hxx>" << endl + << endl; + } + ctx.os << "#include <xsd/cxx/tree/exceptions.hxx>" << endl << "#include <xsd/cxx/tree/elements.hxx>" << endl << "#include <xsd/cxx/tree/containers.hxx>" << endl diff --git a/xsd/cxx/tree/validator.cxx b/xsd/cxx/tree/validator.cxx index 7ef23fa..5742e7a 100644 --- a/xsd/cxx/tree/validator.cxx +++ b/xsd/cxx/tree/validator.cxx @@ -38,6 +38,7 @@ namespace CXX generate_xml_schema, 0, 0, + 0, 0), disabled_warnings_ (disabled_warnings), disabled_warnings_all_ (false), |