From 2615896faa646e5830abf2c269150e1165c66515 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 18 Dec 2020 18:48:46 +0300 Subject: Switch to build2 --- .../cxx/parser/characters-validation-source.cxx | 73 ++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 xsd/xsd/cxx/parser/characters-validation-source.cxx (limited to 'xsd/xsd/cxx/parser/characters-validation-source.cxx') diff --git a/xsd/xsd/cxx/parser/characters-validation-source.cxx b/xsd/xsd/cxx/parser/characters-validation-source.cxx new file mode 100644 index 0000000..749a4cc --- /dev/null +++ b/xsd/xsd/cxx/parser/characters-validation-source.cxx @@ -0,0 +1,73 @@ +// file : xsd/cxx/parser/characters-validation-source.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include + +#include +#include + +namespace CXX +{ + namespace Parser + { + namespace + { + // + // + struct Complex: Traversal::Complex, Context + { + Complex (Context& c) + : Context (c) + { + } + + virtual void + traverse (Type& c) + { + if (!c.mixed_p ()) + return; + + String const& name (ename (c)); + + os <<"// Character validation functions for " << name << "." << endl + <<"//" << endl; + + // _characters_impl + // + os << "bool " << name << "::" << endl + << "_characters_impl (const " << string_type << "& s)" + << "{" + << "this->_any_characters (s);" + << "return true;" + << "}"; + } + }; + } + + void + generate_characters_validation_source (Context& ctx) + { + //@@ Most of the time there is no mixed content type so + // we generate an empty namespace which looks ugly. Will + // need to implement smart namespace to handle this at + // some point. + // + Traversal::Schema schema; + + Sources sources; + Traversal::Names schema_names; + + Namespace ns (ctx); + Traversal::Names names; + + schema >> sources >> schema; + schema >> schema_names >> ns >> names; + + Complex complex (ctx); + + names >> complex; + + schema.dispatch (ctx.schema_root); + } + } +} -- cgit v1.1