diff options
Diffstat (limited to 'xsde/cxx/parser/generator.cxx')
-rw-r--r-- | xsde/cxx/parser/generator.cxx | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/xsde/cxx/parser/generator.cxx b/xsde/cxx/parser/generator.cxx index e59180c..1936286 100644 --- a/xsde/cxx/parser/generator.cxx +++ b/xsde/cxx/parser/generator.cxx @@ -113,6 +113,7 @@ namespace CXX namespace CLI { extern Key type_map = "type-map"; + extern Key char_encoding = "char-encoding"; extern Key no_stl = "no-stl"; extern Key no_iostream = "no-iostream"; extern Key no_exceptions = "no-exceptions"; @@ -188,6 +189,12 @@ namespace CXX << " order of appearance and the first match is used." << endl; + e << "--char-encoding <enc>" << endl + << " Specify the character encoding that should be\n" + << " used for the extracted text data. Valid values\n" + << " are 'utf8' (default) and 'iso8859-1'." + << endl; + e << "--no-stl" << endl << " Generate code that does not use STL." << endl; @@ -514,6 +521,8 @@ namespace CXX { CLI::OptionsSpec spec; + spec.option<CLI::char_encoding> ().default_value ("utf8"); + 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"); @@ -1207,6 +1216,25 @@ namespace CXX hxx << "#include <xsde/cxx/config.hxx>" << endl << endl; + if (ops.value<CLI::char_encoding> () == "iso8859-1") + { + hxx << "#ifndef XSDE_ENCODING_ISO8859_1" << endl + << "#error the generated code uses the ISO-8859-1 encoding" << + "while the XSD/e runtime does not (reconfigure the runtime " << + "or change the --char-encoding value)" << endl + << "#endif" << endl + << endl; + } + else + { + hxx << "#ifndef XSDE_ENCODING_UTF8" << endl + << "#error the generated code uses the UTF-8 encoding" << + "while the XSD/e runtime does not (reconfigure the runtime " << + "or change the --char-encoding value)" << endl + << "#endif" << endl + << endl; + } + if (ops.value<CLI::no_stl> ()) { hxx << "#ifdef XSDE_STL" << endl @@ -1585,6 +1613,14 @@ 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; + + throw Failed (); + } catch (NoNamespaceMapping const& e) { wcerr << e.file () << ":" << e.line () << ":" << e.column () |