From 7db026e8056914d113ac0bbfd9bdc4908a9e7874 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 8 Oct 2010 15:35:23 +0200 Subject: Add support for the whiteSpace facet Use the same mechanism to handle whitespace processing for build-in types and enumerations. --- xsde/cxx/hybrid/parser-header.cxx | 10 ++--- xsde/cxx/hybrid/parser-source.cxx | 78 +++++++++++++++++++++++++++------------ 2 files changed, 58 insertions(+), 30 deletions(-) (limited to 'xsde/cxx/hybrid') 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 () && - !options.value ()) - { - 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 () && !options.value ()) { - // 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 () && - !ctx.options.value ()) + if (ctx.enum_) { // We need this functionality for enum mapping. // - ctx.os << "#include " << endl - << endl; + if (!ctx.options.value () && + !ctx.options.value ()) + ctx.os << "#include " << endl + << endl; + else + ctx.os << "#include " << endl + << endl; } { -- cgit v1.1