diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2010-10-08 15:35:23 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2010-10-08 15:35:23 +0200 |
commit | 7db026e8056914d113ac0bbfd9bdc4908a9e7874 (patch) | |
tree | 0ab15cb8b0ee160a10cca21edaf0aca1e97e8921 /xsde/cxx/hybrid | |
parent | 4f38adc11ab1a3a1ab2dd3f958c917182be7d71f (diff) |
Add support for the whiteSpace facet
Use the same mechanism to handle whitespace processing for build-in types
and enumerations.
Diffstat (limited to 'xsde/cxx/hybrid')
-rw-r--r-- | xsde/cxx/hybrid/parser-header.cxx | 10 | ||||
-rw-r--r-- | xsde/cxx/hybrid/parser-source.cxx | 78 |
2 files changed, 58 insertions, 30 deletions
diff --git a/xsde/cxx/hybrid/parser-header.cxx b/xsde/cxx/hybrid/parser-header.cxx index d67cdca..e64ac63 100644 --- a/xsde/cxx/hybrid/parser-header.cxx +++ b/xsde/cxx/hybrid/parser-header.cxx @@ -135,13 +135,9 @@ namespace CXX // _post // - if (!options.value<CLI::suppress_validation> () && - !options.value<CLI::suppress_parser_val> ()) - { - os << "virtual void" << endl - << "_post ();" - << endl; - } + os << "virtual void" << endl + << "_post ();" + << endl; } diff --git a/xsde/cxx/hybrid/parser-source.cxx b/xsde/cxx/hybrid/parser-source.cxx index 94f05df..64d12d6 100644 --- a/xsde/cxx/hybrid/parser-source.cxx +++ b/xsde/cxx/hybrid/parser-source.cxx @@ -335,13 +335,39 @@ namespace CXX // os << "void " << name << "::" << endl << "_characters (const " << string_type << "& s)" + << "{" + << "if (this->_facets ().whitespace_ == 2 &&" << endl + << "this->" << state << ".str_.size () == 0)" + << "{" + << string_type << " tmp (s.data (), s.size ());" + << endl + << "if (::xsde::cxx::trim_left (tmp) != 0)" << "{"; if (stl) - os << "this->" << state << ".str_.append (s.data (), s.size ());"; + os << "this->" << state << ".str_ += tmp;" + << "}" + << "}" + << "else" << endl + << "this->" << state << ".str_ += s;"; else { if (exceptions) + os << "this->" << state << ".str_.append (tmp.data (), " << + "tmp.size ());"; + else + { + os << "if (this->" << state << ".str_.append (" << + "tmp.data (), tmp.size ()))" << endl + << "this->_sys_error (::xsde::cxx::sys_error::no_memory);"; + } + + os << "}" + << "}" + << "else" + << "{"; + + if (exceptions) os << "this->" << state << ".str_.append (s.data (), s.size ());"; else { @@ -349,34 +375,37 @@ namespace CXX "s.data (), s.size ()))" << endl << "this->_sys_error (::xsde::cxx::sys_error::no_memory);"; } + + os << "}"; } os << "}"; // _post // + os << "void " << name << "::" << endl + << "_post ()" + << "{"; + if (!options.value<CLI::suppress_validation> () && !options.value<CLI::suppress_parser_val> ()) { - // Do facet validation. - // - os << "void " << name << "::" << endl - << "_post ()" - << "{" - << "::xsde::cxx::parser::validating::string_common::" << - "validate_facets (" << endl; - - if (stl) - os << "this->" << state << ".str_.c_str ()," << endl - << "this->" << state << ".str_.size ()," << endl; - else - os << "this->" << state << ".str_.data ()," << endl - << "this->" << state << ".str_.size ()," << endl; + os << "::xsde::cxx::parser::validating::string_common::" << + "validate_facets (" << endl + << "this->" << state << ".str_," << endl + << "this->_facets ()," << endl + << "this->_context ());"; + } + else + { - os << "this->_facets ()," << endl - << "this->_context ());" - << "}"; + os << "::xsde::cxx::parser::non_validating::string_common::" << + "process_facets (" << endl + << "this->" << state << ".str_," << endl + << "this->_facets ());"; } + + os << "}"; } // post @@ -2073,14 +2102,17 @@ namespace CXX Void generate_parser_source (Context& ctx) { - if (ctx.enum_ && - !ctx.options.value<CLI::suppress_validation> () && - !ctx.options.value<CLI::suppress_parser_val> ()) + if (ctx.enum_) { // We need this functionality for enum mapping. // - ctx.os << "#include <xsde/cxx/parser/validating/string-common.hxx>" << endl - << endl; + if (!ctx.options.value<CLI::suppress_validation> () && + !ctx.options.value<CLI::suppress_parser_val> ()) + ctx.os << "#include <xsde/cxx/parser/validating/string-common.hxx>" << endl + << endl; + else + ctx.os << "#include <xsde/cxx/parser/non-validating/string-common.hxx>" << endl + << endl; } { |