diff options
-rw-r--r-- | libxsde/xsde/cxx/serializer/validating/string-common.cxx | 22 | ||||
-rw-r--r-- | libxsde/xsde/cxx/serializer/validating/string-common.hxx | 8 | ||||
-rw-r--r-- | xsde/cxx/hybrid/parser-header.cxx | 29 | ||||
-rw-r--r-- | xsde/cxx/hybrid/parser-source.cxx | 113 | ||||
-rw-r--r-- | xsde/cxx/hybrid/serializer-source.cxx | 28 |
5 files changed, 133 insertions, 67 deletions
diff --git a/libxsde/xsde/cxx/serializer/validating/string-common.cxx b/libxsde/xsde/cxx/serializer/validating/string-common.cxx index 20a1b34..c9c70b8 100644 --- a/libxsde/xsde/cxx/serializer/validating/string-common.cxx +++ b/libxsde/xsde/cxx/serializer/validating/string-common.cxx @@ -16,18 +16,24 @@ namespace xsde { void string_common:: validate_facets (const char* s, -#ifdef XSDE_STL - size_t n, -#endif const string_facets::facets& f, context& ctx) { -#ifndef XSDE_STL - size_t n; - if (f.length_set_ || f.min_length_set_ || f.max_length_set_) - n = strlen (s); -#endif + if (f.length_set_ || + f.min_length_set_ || + f.max_length_set_ || + f.enum_count_ != 0) + { + validate_facets (s, strlen (s), f, ctx); + } + } + void string_common:: + validate_facets (const char* s, + size_t n, + const string_facets::facets& f, + context& ctx) + { if (f.length_set_ && n != f.length_) { ctx.schema_error (schema_error::length_not_equal_prescribed); diff --git a/libxsde/xsde/cxx/serializer/validating/string-common.hxx b/libxsde/xsde/cxx/serializer/validating/string-common.hxx index d7f221d..b49ef5a 100644 --- a/libxsde/xsde/cxx/serializer/validating/string-common.hxx +++ b/libxsde/xsde/cxx/serializer/validating/string-common.hxx @@ -6,7 +6,6 @@ #ifndef XSDE_CXX_SERIALIZER_VALIDATING_STRING_COMMON_HXX #define XSDE_CXX_SERIALIZER_VALIDATING_STRING_COMMON_HXX -#include <xsde/cxx/config.hxx> #include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> namespace xsde @@ -21,9 +20,12 @@ namespace xsde { static void validate_facets (const char* s, -#ifdef XSDE_STL + const string_facets::facets&, + context&); + + static void + validate_facets (const char* s, size_t n, -#endif const string_facets::facets&, context&); }; diff --git a/xsde/cxx/hybrid/parser-header.cxx b/xsde/cxx/hybrid/parser-header.cxx index d3ba4b4..a09375a 100644 --- a/xsde/cxx/hybrid/parser-header.cxx +++ b/xsde/cxx/hybrid/parser-header.cxx @@ -113,17 +113,38 @@ namespace CXX // pre // - os << "virtual void" << endl - << "pre ();" - << endl; + if (!fl || !base_enum) + os << "virtual void" << endl + << "pre ();" + << endl; - // _characters + // _pre // if (!base_enum) os << "virtual void" << endl + << "_pre ();" + << endl; + + if (!base_enum) + { + // _characters + // + os << "virtual void" << endl << "_characters (const " << string_type << "&);" << endl; + // _post + // + if (!options.value<CLI::suppress_validation> () && + !options.value<CLI::suppress_parser_val> ()) + { + os << "virtual void" << endl + << "_post ();" + << endl; + } + } + + // post // String const& ret (pret_type (e)); diff --git a/xsde/cxx/hybrid/parser-source.cxx b/xsde/cxx/hybrid/parser-source.cxx index a1f28e2..7d8c434 100644 --- a/xsde/cxx/hybrid/parser-source.cxx +++ b/xsde/cxx/hybrid/parser-source.cxx @@ -245,27 +245,13 @@ namespace CXX // pre // - os << "void " << name << "::" << endl - << "pre ()" - << "{"; - - if (fl) + if (!fl || !base_enum) { - if (base_enum) - { - // Our base is also fixed-length so call its pre() - // - if (tiein) - os << "this->base_impl_."; - else - os << epimpl (b) << "::"; //@@ fq-name. - - os << "pre ();"; - } + os << "void " << name << "::" << endl + << "pre ()" + << "{"; - // Clear the string buffer. - // - if (!base_enum) + if (fl) { if (stl) os << "this->" << state << ".str_.clear ();"; @@ -281,25 +267,34 @@ namespace CXX } } } - } - else - { - if (exceptions) - os << "this->" << pre_impl_name (e) << " (new " << type << ");"; else - os << type << "* x = new " << type << ";" - << "if (x)" << endl - << "this->" << pre_impl_name (e) << " (x);" - << "else" << endl - << "this->_sys_error (::xsde::cxx::sys_error::no_memory);"; - } + { + if (exceptions) + os << "this->" << pre_impl_name (e) << " (new " << type << ");"; + else + os << type << "* x = new " << type << ";" + << "if (x)" << endl + << "this->" << pre_impl_name (e) << " (x);" + << "else" << endl + << "this->_sys_error (::xsde::cxx::sys_error::no_memory);"; + } - os << "}"; + os << "}"; + } - // _characters - // if (!base_enum) { + // _pre + // + os << "void " << name << "::" << endl + << "_pre ()" + << "{" + // Override it to cut off our base. + // + << "}"; + + // _characters + // os << "void " << name << "::" << endl << "_characters (const " << string_type << "& s)" << "{"; @@ -319,6 +314,31 @@ namespace CXX } os << "}"; + + // _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 << "this->_facets ()," << endl + << "this->_context ());" + << "}"; + } } // post @@ -371,10 +391,6 @@ namespace CXX os << ";"; } - - // - // @@ TODO: check enumerators (switch) - // } else { @@ -388,19 +404,6 @@ namespace CXX names<Enumeration> (e, names_, 0, 0, 0, &Enumeration::comma); - - /* - // @@ Cannot do error checking in post. - - if (!options.value<CLI::suppress_validation> () && - !options.value<CLI::suppress_parser_val> ()) - { - os << "else" << endl - << "this->_schema_error (" << - "::xsde::cxx::schema_error::invalid_enumeration_value);"; - } - */ - os << endl; if (fl) @@ -1787,6 +1790,16 @@ namespace CXX Void generate_parser_source (Context& ctx) { + if (ctx.enum_ && + !ctx.options.value<CLI::suppress_validation> () && + !ctx.options.value<CLI::suppress_parser_val> ()) + { + // We need this functionality for enum mapping. + // + ctx.os << "#include <xsde/cxx/parser/validating/string-common.hxx>" << endl + << endl; + } + { // Emit "weak" header includes for the object model types. // Otherwise we cannot delete the objects of forward-declared diff --git a/xsde/cxx/hybrid/serializer-source.cxx b/xsde/cxx/hybrid/serializer-source.cxx index 87004fa..b15a3bf 100644 --- a/xsde/cxx/hybrid/serializer-source.cxx +++ b/xsde/cxx/hybrid/serializer-source.cxx @@ -204,8 +204,22 @@ namespace CXX os << "void " << name << "::" << endl << "_serialize_content ()" - << "{" - << "this->_characters (this->" << state << "->" << + << "{"; + + if (!options.value<CLI::suppress_validation> () && + !options.value<CLI::suppress_serializer_val> ()) + { + // Do facet validation. + // + os << "::xsde::cxx::serializer::validating::string_common::" << + "validate_facets (" << endl + << "this->" << state << "->" << string << " ()," << endl + << "this->_facets ()," << endl + << "this->_context ());" + << endl; + } + + os << "this->_characters (this->" << state << "->" << string << " ());" << "}"; } @@ -1377,6 +1391,16 @@ namespace CXX ctx.os << "#include <string.h>" << endl << endl; + if (ctx.enum_ && + !ctx.options.value<CLI::suppress_validation> () && + !ctx.options.value<CLI::suppress_serializer_val> ()) + { + // We need this functionality for enum mapping. + // + ctx.os << "#include <xsde/cxx/serializer/validating/string-common.hxx>" << endl + << endl; + } + Traversal::Schema schema; Traversal::Sources sources; |