diff options
Diffstat (limited to 'libxsde/xsde/cxx/serializer')
334 files changed, 23562 insertions, 0 deletions
diff --git a/libxsde/xsde/cxx/serializer/context.cxx b/libxsde/xsde/cxx/serializer/context.cxx new file mode 100644 index 0000000..f340e7a --- /dev/null +++ b/libxsde/xsde/cxx/serializer/context.cxx @@ -0,0 +1,107 @@ +// file : xsde/cxx/serializer/context.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/config.hxx> +#include <xsde/cxx/ro-string.hxx> + +#ifdef XSDE_EXCEPTIONS +# include <new> // std::bad_alloc +# include <xsde/cxx/serializer/exceptions.hxx> +#endif + +#include <xsde/cxx/serializer/context.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { +#ifdef XSDE_POLYMORPHIC +#ifdef XSDE_EXCEPTIONS + void context:: +#else + bool context:: +#endif + set_type (const char* type) + { + ro_string t (type); + const char* prefix = 0; + + size_t pos = t.find (' '); + + if (pos != ro_string::npos) + { + prefix = lookup_namespace_prefix (type + pos + 1); + + //@@ TODO: what if prefix is not found? + // +#ifndef XSDE_EXCEPTIONS + if (prefix == 0) + return false; +#endif + if (*prefix == '\0') + prefix = 0; + } + +#ifdef XSDE_EXCEPTIONS + start_attribute ("http://www.w3.org/2001/XMLSchema-instance", "type"); + + if (prefix) + { + characters (prefix); + characters (":"); + } + + characters (type, pos != ro_string::npos ? pos : t.size ()); + end_attribute (); +#else + if (!start_attribute ( + "http://www.w3.org/2001/XMLSchema-instance", "type")) + return false; + + if (prefix) + { + if (!characters (prefix) || !characters (":")) + return false; + } + + if (!characters (type, pos != ro_string::npos ? pos : t.size ()) || + !end_attribute ()) + return false; + + return true; +#endif + } +#endif // XSDE_POLYMORPHIC + +#ifdef XSDE_EXCEPTIONS + void context:: + throw_xml_error (genx::xml_error e) + { + switch (e) + { + case GENX_ALLOC_FAILED: + { + throw std::bad_alloc (); + } + case GENX_IO_ERROR: + { + // This should never happen with consistent exception + // handling usage since the write/flush functions + // throw exceptions to indicate write failures. + // + throw xml (e); + } + default: + { + throw xml (e); + } + } + } +#endif + } + } +} diff --git a/libxsde/xsde/cxx/serializer/context.hxx b/libxsde/xsde/cxx/serializer/context.hxx new file mode 100644 index 0000000..fe817eb --- /dev/null +++ b/libxsde/xsde/cxx/serializer/context.hxx @@ -0,0 +1,261 @@ +// file : xsde/cxx/serializer/context.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_CONTEXT_HXX +#define XSDE_CXX_SERIALIZER_CONTEXT_HXX + +#include <xsde/cxx/config.hxx> + +#include <stddef.h> // size_t + +#include <xsde/c/genx/genx.h> + +#ifndef XSDE_EXCEPTIONS +# include <xsde/cxx/sys-error.hxx> +#endif + +#include <xsde/cxx/serializer/genx/xml-error.hxx> + +#ifdef XSDE_SERIALIZER_VALIDATION +# include <xsde/cxx/schema-error.hxx> +#endif + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + class context + { + public: + context (genxWriter xml_serializer); + + public: + genxWriter + xml_serializer (); + +#ifdef XSDE_POLYMORPHIC + public: + // Set/get the dynamic serializer type id (as opaque const void*) + // in case of polymorphic serialization. If type id is not set, + // static type is assumed. + // + void + type_id (const void*); + + const void* + type_id (); +#endif + + public: +#ifdef XSDE_EXCEPTIONS + void + start_element (const char* name); + + void + start_element (const char* ns, const char* name); + + void + end_element (); + + void + start_attribute (const char* name); + + void + start_attribute (const char* ns, const char* name); + + void + end_attribute (); + + void + attribute (const char* name, const char* value); + + void + attribute (const char* ns, const char* name, const char* value); + + void + characters (const char*); + + void + characters (const char*, size_t); + + void + declare_namespace (const char* ns, const char* prefix); + + void + declare_default_namespace (const char* ns); + + void + clear_default_namespace (); + + const char* + lookup_namespace_prefix (const char* ns); + +#ifdef XSDE_POLYMORPHIC + void + set_type (const char* type); +#endif +#else + bool + start_element (const char* name); + + bool + start_element (const char* ns, const char* name); + + bool + end_element (); + + bool + start_attribute (const char* name); + + bool + start_attribute (const char* ns, const char* name); + + bool + end_attribute (); + + bool + attribute (const char* name, const char* value); + + bool + attribute (const char* ns, const char* name, const char* value); + + bool + characters (const char*); + + bool + characters (const char*, size_t); + + bool + declare_namespace (const char* ns, const char* prefix); + + bool + declare_default_namespace (const char* ns); + + bool + clear_default_namespace (); + + const char* + lookup_namespace_prefix (const char* ns); + +#ifdef XSDE_POLYMORPHIC + bool + set_type (const char* type); +#endif +#endif + + // Error handling via exceptions. + // + +#ifdef XSDE_EXCEPTIONS + public: + void + throw_xml_error (genx::xml_error); +#endif + + // Error handling via codes. + // + + // Application error. + // +#ifndef XSDE_EXCEPTIONS + public: + int + app_error () const; + + void + app_error (int); +#endif + + // Schema error. + // +#ifdef XSDE_SERIALIZER_VALIDATION + public: + typedef cxx::schema_error::value schema_error_t; + + schema_error_t + schema_error () const; + + void + schema_error (schema_error_t); +#endif + + // XML error. + // +#ifndef XSDE_EXCEPTIONS + public: + typedef genx::xml_error xml_error_t; + + xml_error_t + xml_error () const; + + void + xml_error (xml_error_t); +#endif + + // System error. + // +#ifndef XSDE_EXCEPTIONS + public: + typedef cxx::sys_error::value sys_error_t; + + sys_error_t + sys_error () const; + + void + sys_error (sys_error_t); +#endif + + // Implementation details. + // +#if defined(XSDE_SERIALIZER_VALIDATION) || !defined(XSDE_EXCEPTIONS) + public: + enum error_type_t + { + error_none = 0, + error_app, + error_schema, + error_xml, + error_sys + }; + + error_type_t + error_type () const; + + protected: + error_type_t error_type_; + + union + { +#ifndef XSDE_EXCEPTIONS + int app; + xml_error_t xml; +#endif +#ifdef XSDE_SERIALIZER_VALIDATION + schema_error_t schema; +#endif +#ifndef XSDE_EXCEPTIONS + sys_error_t sys; +#endif + } error_code_; + +#endif // XSDE_SERIALIZER_VALIDATION || !XSDE_EXCEPTIONS + + protected: + genxWriter xml_serializer_; + +#ifdef XSDE_POLYMORPHIC + const void* type_id_; +#endif + + }; + } + } +} + +#include <xsde/cxx/serializer/context.ixx> + +#endif // XSDE_CXX_SERIALIZER_CONTEXT_HXX diff --git a/libxsde/xsde/cxx/serializer/context.ixx b/libxsde/xsde/cxx/serializer/context.ixx new file mode 100644 index 0000000..d3e578d --- /dev/null +++ b/libxsde/xsde/cxx/serializer/context.ixx @@ -0,0 +1,449 @@ +// file : xsde/cxx/serializer/context.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + inline context:: + context (genxWriter xml_serializer) + : xml_serializer_ (xml_serializer) + { +#if defined(XSDE_SERIALIZER_VALIDATION) || !defined(XSDE_EXCEPTIONS) + error_type_ = error_none; +#endif + } + + inline genxWriter context:: + xml_serializer () + { + return xml_serializer_; + } + +#ifdef XSDE_POLYMORPHIC + inline void context:: + type_id (const void* ti) + { + type_id_ = ti; + } + + inline const void* context:: + type_id () + { + return type_id_; + } +#endif + + // + // +#ifdef XSDE_EXCEPTIONS + inline void context:: +#else + inline bool context:: +#endif + start_element (const char* name) + { + genxStatus e = genxStartElementLiteral ( + xml_serializer_, + 0, + reinterpret_cast<constUtf8> (name)); + +#ifdef XSDE_EXCEPTIONS + if (e != GENX_SUCCESS) + throw_xml_error (e); +#else + if (e != GENX_SUCCESS) + xml_error (e); + + return e == GENX_SUCCESS; +#endif + } + + // + // +#ifdef XSDE_EXCEPTIONS + inline void context:: +#else + inline bool context:: +#endif + start_element (const char* ns, const char* name) + { + genxStatus e = genxStartElementLiteral ( + xml_serializer_, + reinterpret_cast<constUtf8> (ns), + reinterpret_cast<constUtf8> (name)); + +#ifdef XSDE_EXCEPTIONS + if (e != GENX_SUCCESS) + throw_xml_error (e); +#else + if (e != GENX_SUCCESS) + xml_error (e); + + return e == GENX_SUCCESS; +#endif + } + + // + // +#ifdef XSDE_EXCEPTIONS + inline void context:: +#else + inline bool context:: +#endif + end_element () + { + genxStatus e = genxEndElement (xml_serializer_); + +#ifdef XSDE_EXCEPTIONS + if (e != GENX_SUCCESS) + throw_xml_error (e); +#else + if (e != GENX_SUCCESS) + xml_error (e); + + return e == GENX_SUCCESS; +#endif + } + + // + // +#ifdef XSDE_EXCEPTIONS + inline void context:: +#else + inline bool context:: +#endif + start_attribute (const char* name) + { + genxStatus e = genxStartAttributeLiteral ( + xml_serializer_, + 0, + reinterpret_cast<constUtf8> (name)); + +#ifdef XSDE_EXCEPTIONS + if (e != GENX_SUCCESS) + throw_xml_error (e); +#else + if (e != GENX_SUCCESS) + xml_error (e); + + return e == GENX_SUCCESS; +#endif + } + + // + // +#ifdef XSDE_EXCEPTIONS + inline void context:: +#else + inline bool context:: +#endif + start_attribute (const char* ns, const char* name) + { + genxStatus e = genxStartAttributeLiteral ( + xml_serializer_, + reinterpret_cast<constUtf8> (ns), + reinterpret_cast<constUtf8> (name)); + +#ifdef XSDE_EXCEPTIONS + if (e != GENX_SUCCESS) + throw_xml_error (e); +#else + if (e != GENX_SUCCESS) + xml_error (e); + + return e == GENX_SUCCESS; +#endif + } + + // + // +#ifdef XSDE_EXCEPTIONS + inline void context:: +#else + inline bool context:: +#endif + end_attribute () + { + genxStatus e = genxEndAttribute (xml_serializer_); + +#ifdef XSDE_EXCEPTIONS + if (e != GENX_SUCCESS) + throw_xml_error (e); +#else + if (e != GENX_SUCCESS) + xml_error (e); + + return e == GENX_SUCCESS; +#endif + } + + // + // +#ifdef XSDE_EXCEPTIONS + inline void context:: +#else + inline bool context:: +#endif + attribute (const char* name, const char* value) + { + genxStatus e = genxAddAttributeLiteral ( + xml_serializer_, + 0, + reinterpret_cast<constUtf8> (name), + reinterpret_cast<constUtf8> (value)); + +#ifdef XSDE_EXCEPTIONS + if (e != GENX_SUCCESS) + throw_xml_error (e); +#else + if (e != GENX_SUCCESS) + xml_error (e); + + return e == GENX_SUCCESS; +#endif + } + + // + // +#ifdef XSDE_EXCEPTIONS + inline void context:: +#else + inline bool context:: +#endif + attribute (const char* ns, const char* name, const char* value) + { + genxStatus e = genxAddAttributeLiteral ( + xml_serializer_, + reinterpret_cast<constUtf8> (ns), + reinterpret_cast<constUtf8> (name), + reinterpret_cast<constUtf8> (value)); + +#ifdef XSDE_EXCEPTIONS + if (e != GENX_SUCCESS) + throw_xml_error (e); +#else + if (e != GENX_SUCCESS) + xml_error (e); + + return e == GENX_SUCCESS; +#endif + } + + // + // +#ifdef XSDE_EXCEPTIONS + inline void context:: +#else + inline bool context:: +#endif + characters (const char* s) + { + genxStatus e = genxAddText ( + xml_serializer_, + reinterpret_cast<constUtf8> (s)); + +#ifdef XSDE_EXCEPTIONS + if (e != GENX_SUCCESS) + throw_xml_error (e); +#else + if (e != GENX_SUCCESS) + xml_error (e); + + return e == GENX_SUCCESS; +#endif + } + + // + // +#ifdef XSDE_EXCEPTIONS + inline void context:: +#else + inline bool context:: +#endif + characters (const char* s, size_t n) + { + genxStatus e = genxAddCountedText ( + xml_serializer_, + reinterpret_cast<constUtf8> (s), + static_cast<int> (n)); + +#ifdef XSDE_EXCEPTIONS + if (e != GENX_SUCCESS) + throw_xml_error (e); +#else + if (e != GENX_SUCCESS) + xml_error (e); + + return e == GENX_SUCCESS; +#endif + } + + // + // +#ifdef XSDE_EXCEPTIONS + inline void context:: +#else + inline bool context:: +#endif + declare_namespace (const char* ns, const char* prefix) + { + genxStatus e = genxAddNamespaceLiteral ( + xml_serializer_, + reinterpret_cast<constUtf8> (ns), + reinterpret_cast<constUtf8> (prefix)); + +#ifdef XSDE_EXCEPTIONS + if (e != GENX_SUCCESS) + throw_xml_error (e); +#else + if (e != GENX_SUCCESS) + xml_error (e); + + return e == GENX_SUCCESS; +#endif + } + + // + // +#ifdef XSDE_EXCEPTIONS + inline void context:: +#else + inline bool context:: +#endif + declare_default_namespace (const char* ns) + { + genxStatus e = genxAddNamespaceLiteral ( + xml_serializer_, + reinterpret_cast<constUtf8> (ns), + reinterpret_cast<constUtf8> ("")); + +#ifdef XSDE_EXCEPTIONS + if (e != GENX_SUCCESS) + throw_xml_error (e); +#else + if (e != GENX_SUCCESS) + xml_error (e); + + return e == GENX_SUCCESS; +#endif + } + + // + // +#ifdef XSDE_EXCEPTIONS + inline void context:: +#else + inline bool context:: +#endif + clear_default_namespace () + { + genxStatus e = genxUnsetDefaultNamespace (xml_serializer_); + +#ifdef XSDE_EXCEPTIONS + if (e != GENX_SUCCESS) + throw_xml_error (e); +#else + if (e != GENX_SUCCESS) + xml_error (e); + + return e == GENX_SUCCESS; +#endif + } + + // + // + inline const char* context:: + lookup_namespace_prefix (const char* ns) + { + genxStatus e; + genxNamespace gns = genxDeclareNamespace ( + xml_serializer_, reinterpret_cast<constUtf8> (ns), 0, &e); + + if (e != GENX_SUCCESS) + { +#ifdef XSDE_EXCEPTIONS + throw_xml_error (e); +#else + xml_error (e); +#endif + return 0; + } + + return reinterpret_cast<const char*> ( + genxGetNamespacePrefix (gns)); + } + + // + // +#ifndef XSDE_EXCEPTIONS + inline int context:: + app_error () const + { + return error_code_.app; + } + + inline void context:: + app_error (int e) + { + error_type_ = error_app; + error_code_.app = e; + } + + inline void context:: + sys_error (sys_error_t e) + { + error_type_ = error_sys; + error_code_.sys = e; + } + + inline context::sys_error_t context:: + sys_error () const + { + return error_code_.sys; + } + + inline void context:: + xml_error (xml_error_t e) + { + error_type_ = error_xml; + error_code_.xml = e; + } + + inline context::xml_error_t context:: + xml_error () const + { + return error_code_.xml; + } +#endif + +#ifdef XSDE_SERIALIZER_VALIDATION + inline context::schema_error_t context:: + schema_error () const + { + return error_code_.schema; + } + + inline void context:: + schema_error (schema_error_t e) + { + error_type_ = error_schema; + error_code_.schema = e; + } +#endif + +#if defined(XSDE_SERIALIZER_VALIDATION) || !defined(XSDE_EXCEPTIONS) + inline context::error_type_t context:: + error_type () const + { + return error_type_; + } +#endif + + } + } +} diff --git a/libxsde/xsde/cxx/serializer/elements.cxx b/libxsde/xsde/cxx/serializer/elements.cxx new file mode 100644 index 0000000..d20601e --- /dev/null +++ b/libxsde/xsde/cxx/serializer/elements.cxx @@ -0,0 +1,122 @@ +// file : xsde/cxx/serializer/elements.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <assert.h> + +#include <xsde/cxx/serializer/elements.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + // serializer_base + // + serializer_base:: + ~serializer_base () + { + } + + void serializer_base:: + _pre () + { +#ifdef XSDE_REUSE_STYLE_TIEIN + if (impl_) + impl_->_pre (); +#endif + } + + void serializer_base:: + _serialize_attributes () + { + } + + void serializer_base:: + _serialize_content () + { + } + + void serializer_base:: + _post () + { +#ifdef XSDE_REUSE_STYLE_TIEIN + if (impl_) + impl_->_post (); +#endif + } + + void serializer_base:: + post () + { +#ifdef XSDE_REUSE_STYLE_TIEIN + if (impl_) + impl_->post (); +#endif + } + + void serializer_base:: + _pre_impl (context& c) + { +#ifdef XSDE_REUSE_STYLE_TIEIN + assert (parent_ == 0); + + // Set the parent_ pointers in the tied-in implementations. + // + _set_parent_chain (); +#endif + ++depth_; + context_ = &c; + + _pre (); + } + + void serializer_base:: + _post_impl () + { +#if defined(XSDE_SERIALIZER_VALIDATION) || !defined(XSDE_EXCEPTIONS) + if (!context_->error_type ()) +#endif + _post (); + + if (--depth_ == 0) + context_ = 0; + } + +#ifdef XSDE_POLYMORPHIC + const char* serializer_base:: + _dynamic_type () const + { + return 0; + } +#endif + + void serializer_base:: + _reset () + { +#ifdef XSDE_REUSE_STYLE_TIEIN + if (impl_) + impl_->_reset (); +#endif + +#ifndef XSDE_EXCEPTIONS + error_type_ = error_none; +#endif + context_ = 0; + depth_ = 0; + } + +#if defined (XSDE_REUSE_STYLE_TIEIN) && !defined (XSDE_EXCEPTIONS) + const serializer_base* serializer_base:: + _ultimate_impl () const + { + const serializer_base* s = impl_; + for (; s->impl_ != 0; s = s->impl_) /*noop*/; + return s; + } +#endif + } + } +} diff --git a/libxsde/xsde/cxx/serializer/elements.hxx b/libxsde/xsde/cxx/serializer/elements.hxx new file mode 100644 index 0000000..f6c354a --- /dev/null +++ b/libxsde/xsde/cxx/serializer/elements.hxx @@ -0,0 +1,302 @@ +// file : xsde/cxx/serializer/elements.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_ELEMENTS_HXX +#define XSDE_CXX_SERIALIZER_ELEMENTS_HXX + +#include <xsde/cxx/config.hxx> + +#include <stddef.h> // size_t + +#include <xsde/cxx/serializer/context.hxx> + +#ifndef XSDE_EXCEPTIONS +# include <xsde/cxx/serializer/error.hxx> +#endif + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + // pre() and post() are overridable pre/post callbacks, i.e., the + // derived serializer can override them without calling the base + // version. _pre() and _post() are not overridable pre/post callbacks + // in the sense that the derived serializer may override them but + // has to call the base version. The call sequence is as shown below: + // + // pre (arg) + // _pre () + // _post () + // post () + // + struct serializer_base + { + virtual + ~serializer_base (); + + serializer_base (); + +#ifdef XSDE_REUSE_STYLE_TIEIN + serializer_base (serializer_base* impl, void*); +#endif + + // The pre() signature varies depending on the serializer argument + // type. + // + + virtual void + _pre (); + + virtual void + _serialize_attributes (); + + virtual void + _serialize_content (); + + virtual void + _post (); + + virtual void + post (); + + // Implementation callbacks for _pre and _post. The _pre and _post + // callbacks should never be called directly. Instead, the *_impl + // versions should be used. The _pre_impl and _post_impl functions + // will eventually call _pre and _post respectively. + // + virtual void + _pre_impl (context&); + + virtual void + _post_impl (); + +#ifdef XSDE_POLYMORPHIC + public: + // Dynamic type in the form "<name> <namespace>" with + // the space and namespace part absent if the type does + // not have a namespace. + // + virtual const char* + _dynamic_type () const; +#endif + + public: + context& + _context (); + + // The XML generation functions below can only be called starting + // from _pre() and ending with _post(). Because namespace declarations + // should come after the start_element and before any attributes, + // _pre is the appropriate place to call the namespace declaration + // functions. If exceptions are disabled, these functions return + // true on success and false otherwise. + // + // The set_type() function sets the xsi:type attribute. Its argument + // is the type id in the form "<name> <namespace>" with the space + // and namespace part absent if the type does not have a namespace. + // +#ifdef XSDE_EXCEPTIONS + void + _start_element (const char* name); + + void + _start_element (const char* ns, const char* name); + + void + _end_element (); + + void + _start_attribute (const char* name); + + void + _start_attribute (const char* ns, const char* name); + + void + _end_attribute (); + + void + _attribute (const char* name, const char* value); + + void + _attribute (const char* ns, const char* name, const char* value); + + void + _characters (const char*); + + void + _characters (const char*, size_t); + + void + _declare_namespace (const char* ns, const char* prefix); + + void + _declare_default_namespace (const char* ns); + + void + _clear_default_namespace (); + + const char* + _lookup_namespace_prefix (const char* ns); + +#ifdef XSDE_POLYMORPHIC + void + _set_type (const char* type); +#endif +#else + bool + _start_element (const char* name); + + bool + _start_element (const char* ns, const char* name); + + bool + _end_element (); + + bool + _start_attribute (const char* name); + + bool + _start_attribute (const char* ns, const char* name); + + bool + _end_attribute (); + + bool + _attribute (const char* name, const char* value); + + bool + _attribute (const char* ns, const char* name, const char* value); + + bool + _characters (const char*); + + bool + _characters (const char*, size_t); + + bool + _declare_namespace (const char* ns, const char* prefix); + + bool + _declare_default_namespace (const char* ns); + + bool + _clear_default_namespace (); + + const char* + _lookup_namespace_prefix (const char* ns); + +#ifdef XSDE_POLYMORPHIC + bool + _set_type (const char* type); +#endif +#endif + // Reset the serializer state after an error. + // + virtual void + _reset (); + + // Error handling via codes. If the error is set while serializer + // is in the context, the error is set in the context, instead + // of the serializer. Since pre() and post() calls are not in + // context, the serializer stores application and system errors + // locally for this case. + // + +#ifndef XSDE_EXCEPTIONS + public: + error + _error () const; + + // Set application error. + // + void + _app_error (int); + + int + _app_error () const; +#endif + + // Schema error. + // +#ifdef XSDE_SERIALIZER_VALIDATION + public: + void + _schema_error (context::schema_error_t); +#endif + + // XML error. + // +#ifndef XSDE_EXCEPTIONS + public: + void + _xml_error (context::xml_error_t); +#endif + + // System error. + // +#ifndef XSDE_EXCEPTIONS + public: + context::sys_error_t + _sys_error () const; + + void + _sys_error (context::sys_error_t); +#endif + + // Implementation. + // +#ifndef XSDE_EXCEPTIONS + public: + enum error_type_t + { + error_none = 0, + error_app, + error_sys + }; + + error_type_t + _error_type () const; + + void + _copy_error (context&) const; + + protected: + error_type_t error_type_; + + union + { + int app; + context::sys_error_t sys; + } error_code_; +#endif + + protected: + bool resetting_; + context* context_; + size_t depth_; + +#ifdef XSDE_REUSE_STYLE_TIEIN + protected: + serializer_base* parent_; + serializer_base* impl_; + + void + _set_parent_chain (); + +#ifndef XSDE_EXCEPTIONS + const serializer_base* + _ultimate_impl () const; +#endif +#endif + }; + } + } +} + +#include <xsde/cxx/serializer/elements.ixx> + +#endif // XSDE_CXX_SERIALIZER_ELEMENTS_HXX diff --git a/libxsde/xsde/cxx/serializer/elements.ixx b/libxsde/xsde/cxx/serializer/elements.ixx new file mode 100644 index 0000000..ead289a --- /dev/null +++ b/libxsde/xsde/cxx/serializer/elements.ixx @@ -0,0 +1,569 @@ +// file : xsde/cxx/serializer/elements.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + inline serializer_base:: + serializer_base () + : resetting_ (false), context_ (0), depth_ (0) + { +#ifndef XSDE_EXCEPTIONS + error_type_ = error_none; +#endif +#ifdef XSDE_REUSE_STYLE_TIEIN + parent_ = 0; + impl_ = 0; +#endif + } + +#ifdef XSDE_REUSE_STYLE_TIEIN + inline serializer_base:: + serializer_base (serializer_base* impl, void*) + : resetting_ (false), context_ (0), depth_ (0) + { +#ifndef XSDE_EXCEPTIONS + error_type_ = error_none; +#endif + parent_ = 0; + impl_ = impl; + } +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + inline void serializer_base:: + _set_parent_chain () + { + if (impl_ && impl_->parent_ == 0) + { + for (serializer_base* s = impl_; s != 0; s = s->impl_) + s->parent_ = this; + } + } +#endif + + inline context& serializer_base:: + _context () + { +#ifdef XSDE_REUSE_STYLE_TIEIN + return *(parent_ ? parent_->context_ : context_); +#else + return *context_; +#endif + } + +#ifdef XSDE_EXCEPTIONS + inline void serializer_base:: + _start_element (const char* name) + { +#ifdef XSDE_REUSE_STYLE_TIEIN + serializer_base* s = parent_ ? parent_ : this; +#else + serializer_base* s = this; +#endif + s->context_->start_element (name); + } + + inline void serializer_base:: + _start_element (const char* ns, const char* name) + { +#ifdef XSDE_REUSE_STYLE_TIEIN + serializer_base* s = parent_ ? parent_ : this; +#else + serializer_base* s = this; +#endif + s->context_->start_element (ns, name); + } + + inline void serializer_base:: + _end_element () + { +#ifdef XSDE_REUSE_STYLE_TIEIN + serializer_base* s = parent_ ? parent_ : this; +#else + serializer_base* s = this; +#endif + s->context_->end_element (); + } + + inline void serializer_base:: + _start_attribute (const char* name) + { +#ifdef XSDE_REUSE_STYLE_TIEIN + serializer_base* s = parent_ ? parent_ : this; +#else + serializer_base* s = this; +#endif + s->context_->start_attribute (name); + } + + inline void serializer_base:: + _start_attribute (const char* ns, const char* name) + { +#ifdef XSDE_REUSE_STYLE_TIEIN + serializer_base* s = parent_ ? parent_ : this; +#else + serializer_base* s = this; +#endif + s->context_->start_attribute (ns, name); + } + + inline void serializer_base:: + _end_attribute () + { +#ifdef XSDE_REUSE_STYLE_TIEIN + serializer_base* s = parent_ ? parent_ : this; +#else + serializer_base* s = this; +#endif + s->context_->end_attribute (); + } + + inline void serializer_base:: + _attribute (const char* name, const char* value) + { +#ifdef XSDE_REUSE_STYLE_TIEIN + serializer_base* s = parent_ ? parent_ : this; +#else + serializer_base* s = this; +#endif + s->context_->attribute (name, value); + } + + inline void serializer_base:: + _attribute (const char* ns, const char* name, const char* value) + { +#ifdef XSDE_REUSE_STYLE_TIEIN + serializer_base* s = parent_ ? parent_ : this; +#else + serializer_base* s = this; +#endif + s->context_->attribute (ns, name, value); + } + + inline void serializer_base:: + _characters (const char* str) + { +#ifdef XSDE_REUSE_STYLE_TIEIN + serializer_base* s = parent_ ? parent_ : this; +#else + serializer_base* s = this; +#endif + s->context_->characters (str); + } + + inline void serializer_base:: + _characters (const char* str, size_t n) + { +#ifdef XSDE_REUSE_STYLE_TIEIN + serializer_base* s = parent_ ? parent_ : this; +#else + serializer_base* s = this; +#endif + s->context_->characters (str, n); + } + + inline void serializer_base:: + _declare_namespace (const char* ns, const char* p) + { +#ifdef XSDE_REUSE_STYLE_TIEIN + serializer_base* s = parent_ ? parent_ : this; +#else + serializer_base* s = this; +#endif + s->context_->declare_namespace (ns, p); + } + + inline void serializer_base:: + _declare_default_namespace (const char* ns) + { +#ifdef XSDE_REUSE_STYLE_TIEIN + serializer_base* s = parent_ ? parent_ : this; +#else + serializer_base* s = this; +#endif + s->context_->declare_default_namespace (ns); + } + + inline void serializer_base:: + _clear_default_namespace () + { +#ifdef XSDE_REUSE_STYLE_TIEIN + serializer_base* s = parent_ ? parent_ : this; +#else + serializer_base* s = this; +#endif + s->context_->clear_default_namespace (); + } + + inline const char* serializer_base:: + _lookup_namespace_prefix (const char* ns) + { +#ifdef XSDE_REUSE_STYLE_TIEIN + serializer_base* s = parent_ ? parent_ : this; +#else + serializer_base* s = this; +#endif + return s->context_->lookup_namespace_prefix (ns); + } + +#ifdef XSDE_POLYMORPHIC + inline void serializer_base:: + _set_type (const char* type) + { +#ifdef XSDE_REUSE_STYLE_TIEIN + serializer_base* s = parent_ ? parent_ : this; +#else + serializer_base* s = this; +#endif + s->context_->set_type (type); + } +#endif + +#else // XSDE_EXCEPTIONS + + inline bool serializer_base:: + _start_element (const char* name) + { +#ifdef XSDE_REUSE_STYLE_TIEIN + serializer_base* s = parent_ ? parent_ : this; +#else + serializer_base* s = this; +#endif + return s->context_->start_element (name); + } + + inline bool serializer_base:: + _start_element (const char* ns, const char* name) + { +#ifdef XSDE_REUSE_STYLE_TIEIN + serializer_base* s = parent_ ? parent_ : this; +#else + serializer_base* s = this; +#endif + return s->context_->start_element (ns, name); + } + + inline bool serializer_base:: + _end_element () + { +#ifdef XSDE_REUSE_STYLE_TIEIN + serializer_base* s = parent_ ? parent_ : this; +#else + serializer_base* s = this; +#endif + return s->context_->end_element (); + } + + inline bool serializer_base:: + _start_attribute (const char* name) + { +#ifdef XSDE_REUSE_STYLE_TIEIN + serializer_base* s = parent_ ? parent_ : this; +#else + serializer_base* s = this; +#endif + return s->context_->start_attribute (name); + } + + inline bool serializer_base:: + _start_attribute (const char* ns, const char* name) + { +#ifdef XSDE_REUSE_STYLE_TIEIN + serializer_base* s = parent_ ? parent_ : this; +#else + serializer_base* s = this; +#endif + return s->context_->start_attribute (ns, name); + } + + inline bool serializer_base:: + _end_attribute () + { +#ifdef XSDE_REUSE_STYLE_TIEIN + serializer_base* s = parent_ ? parent_ : this; +#else + serializer_base* s = this; +#endif + return s->context_->end_attribute (); + } + + inline bool serializer_base:: + _attribute (const char* name, const char* value) + { +#ifdef XSDE_REUSE_STYLE_TIEIN + serializer_base* s = parent_ ? parent_ : this; +#else + serializer_base* s = this; +#endif + return s->context_->attribute (name, value); + } + + inline bool serializer_base:: + _attribute (const char* ns, const char* name, const char* value) + { +#ifdef XSDE_REUSE_STYLE_TIEIN + serializer_base* s = parent_ ? parent_ : this; +#else + serializer_base* s = this; +#endif + return s->context_->attribute (ns, name, value); + } + + inline bool serializer_base:: + _characters (const char* str) + { +#ifdef XSDE_REUSE_STYLE_TIEIN + serializer_base* s = parent_ ? parent_ : this; +#else + serializer_base* s = this; +#endif + return s->context_->characters (str); + } + + inline bool serializer_base:: + _characters (const char* str, size_t n) + { +#ifdef XSDE_REUSE_STYLE_TIEIN + serializer_base* s = parent_ ? parent_ : this; +#else + serializer_base* s = this; +#endif + return s->context_->characters (str, n); + } + + inline bool serializer_base:: + _declare_namespace (const char* ns, const char* p) + { +#ifdef XSDE_REUSE_STYLE_TIEIN + serializer_base* s = parent_ ? parent_ : this; +#else + serializer_base* s = this; +#endif + return s->context_->declare_namespace (ns, p); + } + + inline bool serializer_base:: + _declare_default_namespace (const char* ns) + { +#ifdef XSDE_REUSE_STYLE_TIEIN + serializer_base* s = parent_ ? parent_ : this; +#else + serializer_base* s = this; +#endif + return s->context_->declare_default_namespace (ns); + } + + inline bool serializer_base:: + _clear_default_namespace () + { +#ifdef XSDE_REUSE_STYLE_TIEIN + serializer_base* s = parent_ ? parent_ : this; +#else + serializer_base* s = this; +#endif + return s->context_->clear_default_namespace (); + } + + inline const char* serializer_base:: + _lookup_namespace_prefix (const char* ns) + { +#ifdef XSDE_REUSE_STYLE_TIEIN + serializer_base* s = parent_ ? parent_ : this; +#else + serializer_base* s = this; +#endif + return s->context_->lookup_namespace_prefix (ns); + } + +#ifdef XSDE_POLYMORPHIC + inline bool serializer_base:: + _set_type (const char* type) + { +#ifdef XSDE_REUSE_STYLE_TIEIN + serializer_base* s = parent_ ? parent_ : this; +#else + serializer_base* s = this; +#endif + return s->context_->set_type (type); + } +#endif + +#endif // !XSDE_EXCEPTIONS + + // Error handling. + // +#ifndef XSDE_EXCEPTIONS + inline error serializer_base:: + _error () const + { + // Unlike context, which is stored in the top-level + // serializer, error state is stored in the "bottom- + // level" implementation. It is done this way since the + // error handling mechanism can be used in constructors + // which would otherwise require passing the pointer to + // parent serializer to each implementation's c-tor. + // +#ifdef XSDE_REUSE_STYLE_TIEIN + const serializer_base* s = !impl_ ? this : _ultimate_impl (); +#else + const serializer_base* s = this; +#endif + switch (s->error_type_) + { + case error_sys: + { + return error (s->error_code_.sys); + } + case error_app: + { + return error (s->error_code_.app); + } + default: + { + return error (); + } + } + } + + inline void serializer_base:: + _app_error (int e) + { +#ifdef XSDE_REUSE_STYLE_TIEIN + serializer_base* s = parent_ ? parent_ : this; +#else + serializer_base* s = this; +#endif + + if (s->context_ != 0) + { + s->context_->app_error (e); + } + else + { +#ifdef XSDE_REUSE_STYLE_TIEIN + if (!impl_) + s = this; + else + for (s = impl_; s->impl_ != 0; s = s->impl_) /*noop*/; +#endif + s->error_type_ = error_app; + s->error_code_.app = e; + } + } + + inline int serializer_base:: + _app_error () const + { +#ifdef XSDE_REUSE_STYLE_TIEIN + const serializer_base* s = !impl_ ? this : _ultimate_impl (); +#else + const serializer_base* s = this; +#endif + return s->error_code_.app; + } + + inline void serializer_base:: + _sys_error (context::sys_error_t e) + { +#ifdef XSDE_REUSE_STYLE_TIEIN + serializer_base* s = parent_ ? parent_ : this; +#else + serializer_base* s = this; +#endif + if (s->context_ != 0) + { + s->context_->sys_error (e); + } + else + { +#ifdef XSDE_REUSE_STYLE_TIEIN + if (!impl_) + s = this; + else + for (s = impl_; s->impl_ != 0; s = s->impl_) /*noop*/; +#endif + s->error_type_ = error_sys; + s->error_code_.sys = e; + } + } + + inline context::sys_error_t serializer_base:: + _sys_error () const + { +#ifdef XSDE_REUSE_STYLE_TIEIN + const serializer_base* s = !impl_ ? this : _ultimate_impl (); +#else + const serializer_base* s = this; +#endif + return s->error_code_.sys; + } + + inline void serializer_base:: + _xml_error (context::xml_error_t e) + { +#ifdef XSDE_REUSE_STYLE_TIEIN + serializer_base* s = parent_ ? parent_ : this; +#else + serializer_base* s = this; +#endif + s->context_->xml_error (e); + } + + inline serializer_base::error_type_t serializer_base:: + _error_type () const + { +#ifdef XSDE_REUSE_STYLE_TIEIN + const serializer_base* s = !impl_ ? this : _ultimate_impl (); +#else + const serializer_base* s = this; +#endif + return s->error_type_; + } + + inline void serializer_base:: + _copy_error (context& ctx) const + { +#ifdef XSDE_REUSE_STYLE_TIEIN + const serializer_base* s = !impl_ ? this : _ultimate_impl (); +#else + const serializer_base* s = this; +#endif + switch (s->error_type_) + { + case error_app: + { + ctx.app_error (s->error_code_.app); + break; + } + case error_sys: + { + ctx.sys_error (s->error_code_.sys); + break; + } + default: + break; + } + } +#endif // XSDE_EXCEPTIONS + +#ifdef XSDE_SERIALIZER_VALIDATION + inline void serializer_base:: + _schema_error (context::schema_error_t e) + { +#ifdef XSDE_REUSE_STYLE_TIEIN + serializer_base* s = parent_ ? parent_ : this; +#else + serializer_base* s = this; +#endif + s->context_->schema_error (e); + } +#endif + } + } +} diff --git a/libxsde/xsde/cxx/serializer/error.cxx b/libxsde/xsde/cxx/serializer/error.cxx new file mode 100644 index 0000000..7ee1981 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/error.cxx @@ -0,0 +1,20 @@ +// file : xsde/cxx/serializer/error.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/serializer/error.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + void error:: + true_ () + { + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/error.hxx b/libxsde/xsde/cxx/serializer/error.hxx new file mode 100644 index 0000000..62776e9 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/error.hxx @@ -0,0 +1,121 @@ +// file : xsde/cxx/serializer/error.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_ERROR_HXX +#define XSDE_CXX_SERIALIZER_ERROR_HXX + +#include <xsde/cxx/config.hxx> +#include <xsde/cxx/sys-error.hxx> + +#include <xsde/cxx/serializer/genx/xml-error.hxx> + +#ifdef XSDE_SERIALIZER_VALIDATION +# include <xsde/cxx/schema-error.hxx> +#endif + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + using genx::xml_error; + + // This type is only used when C++ exceptions are not used. + // + struct error + { + enum error_type + { + none, + sys, + xml, + schema, + app + }; + + public: + error_type + type () const; + + // Returns true if there is an error so that you can write + // if (s.error ()) or if (error e = s.error ()). + // + typedef void (error::*bool_convertible) (); + operator bool_convertible () const; + + + // sys + // + public: + error (sys_error::value); + + sys_error + sys_code () const; + + const char* + sys_text () const; + + // xml + // + public: + error (xml_error); + + xml_error + xml_code () const; + + const char* + xml_text () const; + + + // schema + // +#ifdef XSDE_SERIALIZER_VALIDATION + public: + error (schema_error::value); + + schema_error + schema_code () const; + + const char* + schema_text () const; +#endif + + // app + // + public: + error (int app_code); + + int + app_code () const; + + + public: + error (); + + private: + void + true_ (); + + private: + error_type type_; + + union + { + sys_error::value sys; + xml_error xml; +#ifdef XSDE_SERIALIZER_VALIDATION + schema_error::value schema; +#endif + int app; + } code_; + }; + } + } +} + +#include <xsde/cxx/serializer/error.ixx> + +#endif // XSDE_CXX_SERIALIZER_ERROR_HXX diff --git a/libxsde/xsde/cxx/serializer/error.ixx b/libxsde/xsde/cxx/serializer/error.ixx new file mode 100644 index 0000000..73b2196 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/error.ixx @@ -0,0 +1,128 @@ +// file : xsde/cxx/serializer/error.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + inline + error::error_type error:: + type () const + { + return type_; + } + + inline + error:: + operator error::bool_convertible () const + { + return type_ != none ? &error::true_ : 0; + } + + // sys + // + + inline + error:: + error (sys_error::value e) + : type_ (sys) + { + code_.sys = e; + } + + inline + sys_error error:: + sys_code () const + { + return code_.sys; + } + + inline + const char* error:: + sys_text () const + { + return sys_error::text (code_.sys); + } + + // xml + // + inline + error:: + error (xml_error e) + : type_ (xml) + { + code_.xml = e; + } + + inline + xml_error error:: + xml_code () const + { + return code_.xml; + } + + inline + const char* error:: + xml_text () const + { + return genx::xml_error_text (code_.xml); + } + + // schema + // + +#ifdef XSDE_SERIALIZER_VALIDATION + inline + error:: + error (schema_error::value e) + : type_ (schema) + { + code_.schema = e; + } + + inline + schema_error error:: + schema_code () const + { + return code_.schema; + } + + inline + const char* error:: + schema_text () const + { + return schema_error::text (code_.schema); + } +#endif + + // app + // + + inline + error:: + error (int e) + : type_ (app) + { + code_.app = e; + } + + inline + int error:: + app_code () const + { + return code_.app; + } + + inline + error:: + error () + : type_ (none) + { + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/exceptions.cxx b/libxsde/xsde/cxx/serializer/exceptions.cxx new file mode 100644 index 0000000..b6ad765 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/exceptions.cxx @@ -0,0 +1,62 @@ +// file : xsde/cxx/serializer/exceptions.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/config.hxx> + +#ifdef XSDE_IOSTREAM +# include <iostream> +#endif + +#include <xsde/cxx/serializer/exceptions.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + // exception + // + +#ifdef XSDE_IOSTREAM + std::ostream& + operator<< (std::ostream& os, const exception& e) + { + return os << e.text (); + } +#endif + + // xml + // + const char* xml:: + text () const + { + return genx::xml_error_text (code_); + } + + const char* xml:: + what () const throw () + { + return "xml error"; + } + + // schema + // +#ifdef XSDE_SERIALIZER_VALIDATION + const char* schema:: + text () const + { + return schema_error::text (code_); + } + + const char* schema:: + what () const throw () + { + return "schema error"; + } +#endif + } + } +} diff --git a/libxsde/xsde/cxx/serializer/exceptions.hxx b/libxsde/xsde/cxx/serializer/exceptions.hxx new file mode 100644 index 0000000..03c2243 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/exceptions.hxx @@ -0,0 +1,91 @@ +// file : xsde/cxx/serializer/exceptions.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_EXCEPTIONS_HXX +#define XSDE_CXX_SERIALIZER_EXCEPTIONS_HXX + +#include <xsde/cxx/config.hxx> + +#ifdef XSDE_IOSTREAM +# include <iosfwd> +#endif + +#include <xsde/cxx/exceptions.hxx> // xsde::cxx::exception + +#ifdef XSDE_SERIALIZER_VALIDATION +# include <xsde/cxx/schema-error.hxx> +#endif + +#include <xsde/cxx/serializer/genx/xml-error.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + // exception + // + struct exception: xsde::cxx::exception + { + virtual const char* + text () const = 0; + }; + +#ifdef XSDE_IOSTREAM + std::ostream& + operator<< (std::ostream&, const exception&); +#endif + + + // xml + // + using genx::xml_error; + + struct xml: exception + { + xml (xml_error); + + xml_error + code () const; + + virtual const char* + text () const; + + virtual const char* + what () const throw (); + + private: + xml_error code_; + }; + + + // schema + // +#ifdef XSDE_SERIALIZER_VALIDATION + struct schema: exception + { + schema (schema_error); + + schema_error + code () const; + + virtual const char* + text () const; + + virtual const char* + what () const throw (); + + private: + schema_error code_; + }; +#endif + } + } +} + +#include <xsde/cxx/serializer/exceptions.ixx> + +#endif // XSDE_CXX_SERIALIZER_EXCEPTIONS_HXX diff --git a/libxsde/xsde/cxx/serializer/exceptions.ixx b/libxsde/xsde/cxx/serializer/exceptions.ixx new file mode 100644 index 0000000..1f81c47 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/exceptions.ixx @@ -0,0 +1,44 @@ +// file : xsde/cxx/serializer/exceptions.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + // xml + // + inline xml:: + xml (xml_error code) + : code_ (code) + { + } + + inline xml_error xml:: + code () const + { + return code_; + } + + // schema + // +#ifdef XSDE_SERIALIZER_VALIDATION + inline schema:: + schema (schema_error code) + : code_ (code) + { + } + + inline schema_error schema:: + code () const + { + return code_; + } +#endif + } + } +} + diff --git a/libxsde/xsde/cxx/serializer/genx/document.cxx b/libxsde/xsde/cxx/serializer/genx/document.cxx new file mode 100644 index 0000000..bba4b26 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/genx/document.cxx @@ -0,0 +1,822 @@ +// file : xsde/cxx/serializer/genx/document.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/config.hxx> + +#include <string.h> // strlen, strcmp + +#ifdef XSDE_EXCEPTIONS +# include <new> // std::bad_alloc +#endif + +#ifdef XSDE_IOSTREAM +# include <iostream> +#endif + +#ifdef XSDE_EXCEPTIONS +# include <xsde/cxx/serializer/exceptions.hxx> +#else +# include <xsde/cxx/serializer/error.hxx> +#endif + +#include <xsde/cxx/serializer/context.hxx> + +#ifdef XSDE_POLYMORPHIC +# include <xsde/cxx/serializer/substitution-map.hxx> +#endif + +#include <xsde/cxx/serializer/genx/document.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace genx + { +#ifdef XSDE_POLYMORPHIC + static substitution_map_init substitution_map_init_; +#endif + + // writer + // + writer:: + ~writer () + { + } + +#ifdef XSDE_EXCEPTIONS + void writer:: + write (const char* s) + { + write (s, strlen (s)); + } +#else + bool writer:: + write (const char* s) + { + return write (s, strlen (s)); + } +#endif + + // document_simpl + // + + document_simpl:: + ~document_simpl () + { + // Prevents auto-generation of this dtor. + } + + document_simpl:: +#ifdef XSDE_POLYMORPHIC + document_simpl (serializer_base& serializer, + const char* name, + bool, + const char* st) +#else + document_simpl (serializer_base& serializer, const char* name) +#endif + : serializer_ (serializer) + { +#ifdef XSDE_POLYMORPHIC + root_static_type_ = st; +#endif + // Leave root_ns_ uninitialized. + // +#ifdef XSDE_EXCEPTIONS + root_name_.assign (name); +#else + if (root_name_.assign (name)) + error_ = error (sys_error::no_memory); +#endif + } + + document_simpl:: +#ifdef XSDE_POLYMORPHIC + document_simpl (serializer_base& serializer, + const char* ns, + const char* name, + bool, + const char* st) +#else + document_simpl (serializer_base& serializer, + const char* ns, + const char* name) +#endif + : serializer_ (serializer) + { +#ifdef XSDE_POLYMORPHIC + root_static_type_ = st; +#endif +#ifdef XSDE_EXCEPTIONS + root_ns_.assign (ns); + root_name_.assign (name); +#else + if (root_ns_.assign (ns) || root_name_.assign (name)) + error_ = error (sys_error::no_memory); +#endif + } + +#ifdef XSDE_STL + document_simpl:: +#ifdef XSDE_POLYMORPHIC + document_simpl (serializer_base& serializer, + const std::string& name, + bool, + const char* st) +#else + document_simpl (serializer_base& serializer, const std::string& name) +#endif + : serializer_ (serializer) + { +#ifdef XSDE_POLYMORPHIC + root_static_type_ = st; +#endif + // Leave root_ns_ uninitialized. + // +#ifdef XSDE_EXCEPTIONS + root_name_.assign (name.c_str (), name.size ()); +#else + if (root_name_.assign (name.c_str (), name.size ())) + error_ = error (sys_error::no_memory); +#endif + } + + document_simpl:: +#ifdef XSDE_POLYMORPHIC + document_simpl (serializer_base& serializer, + const std::string& ns, + const std::string& name, + bool, + const char* st) +#else + document_simpl (serializer_base& serializer, + const std::string& ns, + const std::string& name) +#endif + : serializer_ (serializer) + { +#ifdef XSDE_POLYMORPHIC + root_static_type_ = st; +#endif +#ifdef XSDE_EXCEPTIONS + root_ns_.assign (ns.c_str (), ns.size ()); + root_name_.assign (name.c_str (), name.size ()); +#else + if (root_ns_.assign (ns.c_str (), ns.size ()) || + root_name_.assign (name.c_str (), name.size ())) + error_ = error (sys_error::no_memory); +#endif + } +#endif // XSDE_STL + + + void document_simpl:: + add_prefix (const char* p, const char* ns) + { +#if defined (XSDE_STL) + prefixes_.push_back (p); + prefix_namespaces_.push_back (ns); +#else +#if defined (XSDE_EXCEPTIONS) + prefixes_.push_back_copy (p); + prefix_namespaces_.push_back_copy (ns); +#else + if (prefixes_.push_back_copy (p) || + prefix_namespaces_.push_back_copy (ns)) + error_ = error (sys_error::no_memory); +#endif +#endif + } + + void document_simpl:: + add_default_prefix (const char* ns) + { +#if defined (XSDE_STL) + prefixes_.push_back (""); + prefix_namespaces_.push_back (ns); +#else +#if defined (XSDE_EXCEPTIONS) + prefixes_.push_back_copy (""); + prefix_namespaces_.push_back_copy (ns); +#else + if (prefixes_.push_back_copy ("") || + prefix_namespaces_.push_back_copy (ns)) + error_ = error (sys_error::no_memory); +#endif +#endif + } + + void document_simpl:: + add_schema (const char* ns, const char* l) + { +#if defined (XSDE_STL) + schemas_.push_back (l); + schema_namespaces_.push_back (ns); +#else +#if defined (XSDE_EXCEPTIONS) + schemas_.push_back_copy (l); + schema_namespaces_.push_back_copy (ns); +#else + if (schemas_.push_back_copy (l) || + schema_namespaces_.push_back_copy (ns)) + error_ = error (sys_error::no_memory); +#endif +#endif + } + + void document_simpl:: + add_no_namespace_schema (const char* l) + { +#if defined (XSDE_STL) + schemas_.push_back (l); + schema_namespaces_.push_back (""); +#else +#if defined (XSDE_EXCEPTIONS) + schemas_.push_back_copy (l); + schema_namespaces_.push_back_copy (""); +#else + if (schemas_.push_back_copy (l) || + schema_namespaces_.push_back_copy ("")) + error_ = error (sys_error::no_memory); +#endif +#endif + } + + // + // + void document_simpl:: + reset () + { +#ifndef XSDE_EXCEPTIONS + error_ = error (); +#endif + if (xml_serializer_) + genxReset (xml_serializer_); + + serializer_._reset (); + } + + // istream + // +#ifdef XSDE_IOSTREAM + +#ifdef XSDE_EXCEPTIONS + static void + ostream_write (void* p, const char* s, size_t n) + { + std::ostream* os = reinterpret_cast<std::ostream*> (p); + os->write (s, static_cast<std::streamsize> (n)); + + if (os->bad ()) + throw std::ios_base::failure ("write failed"); + } + + static void + ostream_flush (void* p) + { + std::ostream* os = reinterpret_cast<std::ostream*> (p); + os->flush (); + + if (os->bad ()) + throw std::ios_base::failure ("flush failed"); + } +#else + static bool + ostream_write (void* p, const char* s, size_t n) + { + std::ostream* os = reinterpret_cast<std::ostream*> (p); + os->write (s, static_cast<std::streamsize> (n)); + return !os->bad (); + } + + static bool + ostream_flush (void* p) + { + std::ostream* os = reinterpret_cast<std::ostream*> (p); + os->flush (); + return !os->bad (); + } +#endif + + void document_simpl:: + serialize (std::ostream& os) + { + serialize (&ostream_write, &ostream_flush, &os); + } +#endif // XSDE_IOSTREAM + + // + // +#ifdef XSDE_EXCEPTIONS + static void + write_thunk (void* p, const char* s) + { + reinterpret_cast<writer*> (p)->write (s); + } + + static void + write_bound_thunk (void* p, const char* s, size_t n) + { + reinterpret_cast<writer*> (p)->write (s, n); + } + + static void + flush_thunk (void* p) + { + reinterpret_cast<writer*> (p)->flush (); + } +#else + static bool + write_thunk (void* p, const char* s) + { + return reinterpret_cast<writer*> (p)->write (s); + } + + static bool + write_bound_thunk (void* p, const char* s, size_t n) + { + return reinterpret_cast<writer*> (p)->write (s, n); + } + + static bool + flush_thunk (void* p) + { + return reinterpret_cast<writer*> (p)->flush (); + } +#endif + + void document_simpl:: + serialize (writer& w) + { + serialize (&write_thunk, &write_bound_thunk, &flush_thunk, &w); + } + + // Genx write functions. + // + struct writer_info + { + void* user_data; + document_simpl::write_func write; + document_simpl::write_bound_func write_bound; + document_simpl::flush_func flush; + }; + + extern "C" genxStatus + genx_write (void* p, constUtf8 us) + { + const char* s = reinterpret_cast<const char*> (us); + writer_info* wi = reinterpret_cast<writer_info*> (p); + + if (wi->write != 0) + { +#ifdef XSDE_EXCEPTIONS + wi->write (wi->user_data, s); +#else + if (!wi->write (wi->user_data, s)) + return GENX_IO_ERROR; +#endif + } + else + { +#ifdef XSDE_EXCEPTIONS + wi->write_bound (wi->user_data, s, strlen (s)); +#else + if (!wi->write_bound (wi->user_data, s, strlen (s))) + return GENX_IO_ERROR; +#endif + } + + return GENX_SUCCESS; + } + + extern "C" genxStatus + genx_write_bound (void* p, constUtf8 start, constUtf8 end) + { + size_t size = static_cast<size_t> (end - start); + const char* s = reinterpret_cast<const char*> (start); + writer_info* wi = reinterpret_cast<writer_info*> (p); + +#ifdef XSDE_EXCEPTIONS + wi->write_bound (wi->user_data, s, size); +#else + if (!wi->write_bound (wi->user_data, s, size)) + return GENX_IO_ERROR; +#endif + + return GENX_SUCCESS; + } + + extern "C" genxStatus + genx_flush (void* p) + { + writer_info* wi = reinterpret_cast<writer_info*> (p); + +#ifdef XSDE_EXCEPTIONS + wi->flush (wi->user_data); +#else + if (!wi->flush (wi->user_data)) + return GENX_IO_ERROR; +#endif + + return GENX_SUCCESS; + } + + void document_simpl:: + serialize (write_func w, write_bound_func wb, flush_func f, + void* user_data) + { + if (xml_serializer_ == 0) + { + xml_serializer_ = genxNew (0, 0, 0); + + if (xml_serializer_ == 0) + { +#ifdef XSDE_EXCEPTIONS + throw std::bad_alloc (); +#else + error_ = error (sys_error::no_memory); + return; +#endif + } + } + + writer_info wi; + wi.user_data = user_data; + wi.write = w; + wi.write_bound = wb; + wi.flush = f; + + genxSetUserData (xml_serializer_, &wi); + + genxSender sender; + sender.send = &genx_write; + sender.sendBounded = &genx_write_bound; + sender.flush = &genx_flush; + + genxStatus e = genxStartDocSender (xml_serializer_, &sender); + + if (e != GENX_SUCCESS) + { + filter_xml_error (e); + return; + } + + serialize (xml_serializer_); + +#ifndef XSDE_EXCEPTIONS + if (error_) + return; +#endif + + e = genxEndDocument (xml_serializer_); + + if (e != GENX_SUCCESS) + filter_xml_error (e); + } + + // + // + static const char xsi[] = "http://www.w3.org/2001/XMLSchema-instance"; + + void document_simpl:: + serialize (genxWriter s) + { +#ifndef XSDE_POLYMORPHIC + genxStatus e = genxStartElementLiteral ( + s, + reinterpret_cast<constUtf8> (root_ns_.data ()), + reinterpret_cast<constUtf8> (root_name_.data ())); +#else + const char* ns = root_ns_.data (); + const char* n = root_name_.data (); + const char* dt = 0; + + if (root_static_type_ != 0) + { + dt = serializer_._dynamic_type (); + + // Call to check sets ns and n if successful. + // + if (strcmp (dt, root_static_type_) == 0 || + substitution_map_instance ().check (ns, n, dt)) + dt = 0; + } + + genxStatus e = genxStartElementLiteral ( + s, + reinterpret_cast<constUtf8> (ns), + reinterpret_cast<constUtf8> (n)); + +#endif // XSDE_POLYMORPHIC + + if (e != GENX_SUCCESS) + { + filter_xml_error (e); + return; + } + + // Add namespace prefixes. + // + for (size_t i = 0; i < prefixes_.size (); ++i) + { +#ifdef XSDE_STL + e = genxAddNamespaceLiteral ( + s, + reinterpret_cast<constUtf8> (prefix_namespaces_[i].c_str ()), + reinterpret_cast<constUtf8> (prefixes_[i].c_str ())); +#else + e = genxAddNamespaceLiteral ( + s, + reinterpret_cast<constUtf8> (prefix_namespaces_[i]), + reinterpret_cast<constUtf8> (prefixes_[i])); +#endif + if (e != GENX_SUCCESS) + break; + } + + if (e != GENX_SUCCESS) + { + filter_xml_error (e); + return; + } + + // Add the schema location attributes. + // + if (schemas_.size () != 0) + { + e = genxAddNamespaceLiteral ( + s, + reinterpret_cast<constUtf8> (xsi), + reinterpret_cast<constUtf8> ("xsi")); + + if (e != GENX_SUCCESS) + { + filter_xml_error (e); + return; + } + + // First add the xsi:schemaLocation attribute. + // + bool start = false; + + for (size_t j = 0; j < schemas_.size (); ++j) + { +#ifdef XSDE_STL + const char* l = schemas_[j].c_str (); + const char* ns = schema_namespaces_[j].c_str (); +#else + const char* l = schemas_[j]; + const char* ns = schema_namespaces_[j]; +#endif + if (ns[0] != '\0') + { + if (!start) + { + e = genxStartAttributeLiteral ( + s, + reinterpret_cast<constUtf8> (xsi), + reinterpret_cast<constUtf8> ("schemaLocation")); + + if (e != GENX_SUCCESS) + break; + + start = true; + } + else + { + e = genxAddCharacter (s, ' '); + + if (e != GENX_SUCCESS) + break; + } + + e = genxAddText (s, reinterpret_cast<constUtf8> (ns)); + + if (e != GENX_SUCCESS) + break; + + e = genxAddCharacter (s, ' '); + + if (e != GENX_SUCCESS) + break; + + e = genxAddText (s, reinterpret_cast<constUtf8> (l)); + + if (e != GENX_SUCCESS) + break; + } + } + + if (e != GENX_SUCCESS) + { + filter_xml_error (e); + return; + } + + if (start) + { + e = genxEndAttribute (s); + + if (e != GENX_SUCCESS) + { + filter_xml_error (e); + return; + } + } + + // Now add the xsi:noNamespaceSchemaLocation attribute. + // + start = false; + + for (size_t k = 0; k < schemas_.size (); ++k) + { +#ifdef XSDE_STL + const char* l = schemas_[k].c_str (); + const char* ns = schema_namespaces_[k].c_str (); +#else + const char* l = schemas_[k]; + const char* ns = schema_namespaces_[k]; +#endif + if (ns[0] == '\0') + { + if (!start) + { + e = genxStartAttributeLiteral ( + s, + reinterpret_cast<constUtf8> (xsi), + reinterpret_cast<constUtf8> ("noNamespaceSchemaLocation")); + + if (e != GENX_SUCCESS) + break; + + start = true; + } + else + { + e = genxAddCharacter (s, ' '); + + if (e != GENX_SUCCESS) + break; + } + + e = genxAddText (s, reinterpret_cast<constUtf8> (l)); + + if (e != GENX_SUCCESS) + break; + } + } + + if (e != GENX_SUCCESS) + { + filter_xml_error (e); + return; + } + + if (start) + { + e = genxEndAttribute (s); + + if (e != GENX_SUCCESS) + { + filter_xml_error (e); + return; + } + } + } + + // Call the root type serializer to serialize the content. + // + context ctx (s); + +#if !defined (XSDE_SERIALIZER_VALIDATION) && defined (XSDE_EXCEPTIONS) + +#ifdef XSDE_POLYMORPHIC + // Set xsi:type if necessary. + // + if (dt != 0) + ctx.set_type (dt); +#endif + serializer_._pre_impl (ctx); + serializer_._serialize_attributes (); + serializer_._serialize_content (); + serializer_._post_impl (); + +#else // !defined (XSDE_SERIALIZER_VALIDATION) && defined (XSDE_EXCEPTIONS) + +#ifdef XSDE_POLYMORPHIC + // Set xsi:type if necessary. + // + if (dt != 0) + ctx.set_type (dt); + +#ifndef XSDE_EXCEPTIONS + if (!ctx.error_type ()) +#endif +#endif // XSDE_POLYMORPHIC + + serializer_._pre_impl (ctx); + + if (!ctx.error_type ()) + serializer_._serialize_attributes (); + + if (!ctx.error_type ()) + serializer_._serialize_content (); + + if (!ctx.error_type ()) + serializer_._post_impl (); + + if (context::error_type_t et = ctx.error_type ()) + { + switch (et) + { +#ifndef XSDE_EXCEPTIONS + case context::error_app: + { + error_ = error (ctx.app_error ()); + break; + } +#endif +#ifdef XSDE_SERIALIZER_VALIDATION + case context::error_schema: + { +#ifdef XSDE_EXCEPTIONS + throw schema (ctx.schema_error ()); +#else + error_ = error (ctx.schema_error ()); + break; +#endif + } +#endif +#ifndef XSDE_EXCEPTIONS + case context::error_xml: + { + filter_xml_error (ctx.xml_error ()); + break; + } + case context::error_sys: + { + error_ = error (ctx.sys_error ()); + break; + } +#endif + default: + break; + } + return; + } +#endif // !XSDE_SERIALIZER_VALIDATION && XSDE_EXCEPTIONS + + + e = genxEndElement (s); + + if (e != GENX_SUCCESS) + filter_xml_error (e); + } + + void document_simpl:: + filter_xml_error (genxStatus e) + { + switch (e) + { + case GENX_ALLOC_FAILED: + { +#ifdef XSDE_EXCEPTIONS + throw std::bad_alloc (); +#else + error_ = error (sys_error::no_memory); + break; +#endif + } + case GENX_IO_ERROR: + { +#ifdef XSDE_EXCEPTIONS + // This should never happen with consistent exception + // handling usage since the write/flush functions + // throw exceptions to indicate write failures. + // + throw xml (e); +#else + error_ = error (sys_error::write_failed); + break; +#endif + } + default: + { +#ifdef XSDE_EXCEPTIONS + throw xml (e); +#else + error_ = error (e); + break; +#endif + } + } + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/genx/document.hxx b/libxsde/xsde/cxx/serializer/genx/document.hxx new file mode 100644 index 0000000..19117d6 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/genx/document.hxx @@ -0,0 +1,280 @@ +// file : xsde/cxx/serializer/genx/document.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_GENX_DOCUMENT_HXX +#define XSDE_CXX_SERIALIZER_GENX_DOCUMENT_HXX + +#include <xsde/cxx/config.hxx> + +#include <stddef.h> // size_t + +#include <xsde/c/genx/genx.h> + +#ifdef XSDE_IOSTREAM +# include <iosfwd> +#endif + +#include <xsde/cxx/string.hxx> + +#ifdef XSDE_STL +# include <xsde/cxx/string-sequence-stl.hxx> +#else +# include <xsde/cxx/string-sequence.hxx> +#endif + +#include <xsde/cxx/serializer/elements.hxx> + +#ifndef XSDE_EXCEPTIONS +# include <xsde/cxx/serializer/error.hxx> +#endif + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace genx + { + // Simple auto pointer for genxWriter object. + // + struct serializer_auto_ptr + { + ~serializer_auto_ptr (); + + explicit + serializer_auto_ptr (genxWriter = 0); + + serializer_auto_ptr& + operator= (genxWriter); + + public: + operator genxWriter () + { + return serializer_; + } + + private: + serializer_auto_ptr (const serializer_auto_ptr&); + + serializer_auto_ptr& + operator= (const serializer_auto_ptr&); + + private: + genxWriter serializer_; + }; + + // Writer interface. + // + struct writer + { + virtual + ~writer (); + + // The first write function is called to write a '\0'-terminated + // string. Its default implementation calls the second versions: + // write (s, strlen (s)). If exceptions are enabled, throw to + // indicate a write failure. Otherwise return true if write was + // successful, false otherwise. + // +#ifdef XSDE_EXCEPTIONS + virtual void + write (const char* s); + + virtual void + write (const char* s, size_t n) = 0; + + virtual void + flush () = 0; +#else + virtual bool + write (const char* s); + + virtual bool + write (const char* s, size_t n) = 0; + + virtual bool + flush () = 0; +#endif + }; + + // + // + class document_simpl + { + public: + virtual + ~document_simpl (); + +#ifdef XSDE_POLYMORPHIC + // Note that the static_type string is not deep-copied. + // + document_simpl (serializer_base&, + const char* root_element_name, + bool polymorphic = false, + const char* root_static_type = 0); + + document_simpl (serializer_base&, + const char* root_element_namespace, + const char* root_element_name, + bool polymorphic = false, + const char* root_static_type = 0); + +#ifdef XSDE_STL + document_simpl (serializer_base&, + const std::string& root_element_name, + bool polymorphic = false, + const char* root_static_type = 0); + + document_simpl (serializer_base&, + const std::string& root_element_namespace, + const std::string& root_element_name, + bool polymorphic = false, + const char* root_static_type = 0); +#endif + +#else // XSDE_POLYMORPHIC + + document_simpl (serializer_base&, + const char* root_element_name); + + document_simpl (serializer_base&, + const char* root_element_namespace, + const char* root_element_name); + +#ifdef XSDE_STL + document_simpl (serializer_base&, + const std::string& root_element_name); + + document_simpl (serializer_base&, + const std::string& root_element_namespace, + const std::string& root_element_name); +#endif +#endif // XSDE_POLYMORPHIC + + public: + // Namespace and schema location. + // + void + add_prefix (const char* prefix, const char* namespace_); + + void + add_default_prefix (const char* namespace_); + + void + add_schema (const char* namespace_, const char* location); + + void + add_no_namespace_schema (const char* location); + +#ifdef XSDE_STL + void + add_prefix (const std::string& prefix, + const std::string& namespace_); + + void + add_default_prefix (const std::string& namespace_); + + void + add_schema (const std::string& namespace_, + const std::string& location); + + void + add_no_namespace_schema (const std::string& location); +#endif + + public: + void + reset (); + +#ifdef XSDE_IOSTREAM + public: + // Serialize to std::ostream. The std::ios_base::failure + // exception is used to report io errors (badbit and failbit) + // if XSDE_EXCEPTIONS is defined. Otherwise error codes are + // used. + // + void + serialize (std::ostream&); +#endif + + public: + // Serialize by calling writer::write() and writer::flush() to + // output XML. + // + void + serialize (writer&); + + // Serialize by calling the write and flush functions. If the + // unbounded write function is not provided, the bounded version + // is called: write_bound_func (s, strlen (s)). user_data is + // passed as a first argument to these functions. If exceptions + // are enabled, throw to indicate a write failure. Otherwise return + // true if write was successful, false otherwise. + // + +#ifdef XSDE_EXCEPTIONS + typedef void (*write_func) (void*, const char*); + typedef void (*write_bound_func) (void*, const char*, size_t); + typedef void (*flush_func) (void*); +#else + typedef bool (*write_func) (void*, const char*); + typedef bool (*write_bound_func) (void*, const char*, size_t); + typedef bool (*flush_func) (void*); +#endif + + void + serialize (write_bound_func, flush_func, void* user_data); + + void + serialize (write_func, write_bound_func, flush_func, void* user_data); + + public: + // Low-level, genx-specific serialization. With this method + // it is your responsibility to call genxStartDoc*() and + // genxEndDocument(). + // + void + serialize (genxWriter); + +#ifndef XSDE_EXCEPTIONS + public: + const error& + _error () const; +#endif + + protected: + void + filter_xml_error (genxStatus); + + protected: + serializer_auto_ptr xml_serializer_; + serializer_base& serializer_; + + string root_name_; + string root_ns_; + +#ifdef XSDE_POLYMORPHIC + const char* root_static_type_; +#endif + + string_sequence prefixes_; + string_sequence prefix_namespaces_; + + string_sequence schemas_; + string_sequence schema_namespaces_; + +#ifndef XSDE_EXCEPTIONS + error error_; +#endif + }; + } + } + } +} + +#include <xsde/cxx/serializer/genx/document.ixx> + +#endif // XSDE_CXX_SERIALIZER_GENX_DOCUMENT_HXX diff --git a/libxsde/xsde/cxx/serializer/genx/document.ixx b/libxsde/xsde/cxx/serializer/genx/document.ixx new file mode 100644 index 0000000..7269fa6 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/genx/document.ixx @@ -0,0 +1,84 @@ +// file : xsde/cxx/serializer/genx/document.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace genx + { + // serializer_auto_ptr + // + inline serializer_auto_ptr:: + ~serializer_auto_ptr () + { + if (serializer_ != 0) + genxDispose (serializer_); + } + + inline serializer_auto_ptr:: + serializer_auto_ptr (genxWriter serializer) + : serializer_ (serializer) + { + } + + inline serializer_auto_ptr& serializer_auto_ptr:: + operator= (genxWriter serializer) + { + if (serializer_ != 0) + genxDispose (serializer_); + + serializer_ = serializer; + return *this; + } + + // document_simpl + // + +#ifdef XSDE_STL + inline void document_simpl:: + add_prefix (const std::string& p, const std::string& ns) + { + add_prefix (p.c_str (), ns.c_str ()); + } + + inline void document_simpl:: + add_default_prefix (const std::string& ns) + { + add_default_prefix (ns.c_str ()); + } + + inline void document_simpl:: + add_schema (const std::string& ns, const std::string& l ) + { + add_schema (ns.c_str (), l.c_str ()); + } + + inline void document_simpl:: + add_no_namespace_schema (const std::string& l) + { + add_no_namespace_schema (l.c_str ()); + } +#endif + + inline void document_simpl:: + serialize (write_bound_func wb, flush_func f, void* user_data) + { + serialize (0, wb, f, user_data); + } + +#ifndef XSDE_EXCEPTIONS + inline const error& document_simpl:: + _error () const + { + return error_; + } +#endif + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/genx/xml-error.cxx b/libxsde/xsde/cxx/serializer/genx/xml-error.cxx new file mode 100644 index 0000000..8abc7a6 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/genx/xml-error.cxx @@ -0,0 +1,48 @@ +// file : xsde/cxx/serializer/genx/xml-error.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/serializer/genx/xml-error.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace genx + { + static const char* const text_[] = + { + "no error", + "illegal UTF-8 character", + "illegal XML character", + "illegal name", + "out of memory", + "illegal namespace name", + "internal error", + "duplicate prefix", + "call out of sequence", + "mismatched end element call", + "output error", + "missing attribute value", + "malformed comment body", + "illegal character sequence in processing instruction", + "processing instruction target is XML", + "duplicate attribute", + "attribute in default namespace", + "different prefixes for the same namespace in the same element", + "default namespace in an unqualified element" + }; + + const char* + xml_error_text (xml_error e) + { + return text_[e]; + } + } + } + } +} + diff --git a/libxsde/xsde/cxx/serializer/genx/xml-error.hxx b/libxsde/xsde/cxx/serializer/genx/xml-error.hxx new file mode 100644 index 0000000..6287952 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/genx/xml-error.hxx @@ -0,0 +1,28 @@ +// file : xsde/cxx/serializer/genx/xml-error.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_GENX_XML_ERROR_HXX +#define XSDE_CXX_SERIALIZER_GENX_XML_ERROR_HXX + +#include <xsde/c/genx/genx.h> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace genx + { + typedef genxStatus xml_error; + + const char* + xml_error_text (xml_error); + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_GENX_XML_ERROR_HXX diff --git a/libxsde/xsde/cxx/serializer/map.cxx b/libxsde/xsde/cxx/serializer/map.cxx new file mode 100644 index 0000000..1ace4ac --- /dev/null +++ b/libxsde/xsde/cxx/serializer/map.cxx @@ -0,0 +1,35 @@ +// file : xsde/cxx/serializer/map.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/serializer/map.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + // serializer_map + // + serializer_map:: + ~serializer_map () + { + } + + // serializer_map_impl + // + void serializer_map_impl:: + reset () const + { + for (hashmap::const_iterator i (map_.begin ()), e (map_.end ()); + i != e; ++i) + { + serializer_base* s = *static_cast<serializer_base* const*> (*i); + s->_reset (); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/map.hxx b/libxsde/xsde/cxx/serializer/map.hxx new file mode 100644 index 0000000..2cfc755 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/map.hxx @@ -0,0 +1,96 @@ +// file : xsde/cxx/serializer/map.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_MAP_HXX +#define XSDE_CXX_SERIALIZER_MAP_HXX + +#include <stddef.h> // size_t + +#include <xsde/cxx/config.hxx> +#include <xsde/cxx/hashmap.hxx> + +#include <xsde/cxx/serializer/elements.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + // Serializer map. Used in the polymorphic document parsing. + // + class serializer_map + { + public: + // The type_id argument is the application-specific type id + // object (passed as opaque const void*) that was set by the + // callback in the context or 0 if no type id was provided. + // + virtual serializer_base* + find (const void* type_id) const = 0; + + // Reset the serializers this map contains. + // + virtual void + reset () const = 0; + + virtual + ~serializer_map (); + }; + + // Default serializer map implementation. It assumes that the + // type id is a C string (const char*). + // + class serializer_map_impl: public serializer_map + { + public: +#ifndef XSDE_EXCEPTIONS + enum error + { + error_none, + error_no_memory + }; + + error + _error () const; +#endif + + public: + serializer_map_impl (size_t buckets); + + // Note that the type_id string is not copied so it should + // be valid for the lifetime of the map. + // + void + insert (const char* type_id, serializer_base&); + + // This version of insert is a shortcut that uses the string + // returned by the serializer's _dynamic_type() function. + // + void + insert (serializer_base&); + + virtual serializer_base* + find (const void* type_id) const; + + virtual void + reset () const; + + private: + serializer_map_impl (const serializer_map_impl&); + + serializer_map_impl& + operator= (const serializer_map_impl&); + + private: + hashmap map_; + }; + } + } +} + +#include <xsde/cxx/serializer/map.ixx> + +#endif // XSDE_CXX_SERIALIZER_MAP_HXX diff --git a/libxsde/xsde/cxx/serializer/map.ixx b/libxsde/xsde/cxx/serializer/map.ixx new file mode 100644 index 0000000..64eb19a --- /dev/null +++ b/libxsde/xsde/cxx/serializer/map.ixx @@ -0,0 +1,51 @@ +// file : xsde/cxx/serializer/map.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { +#ifndef XSDE_EXCEPTIONS + inline serializer_map_impl::error serializer_map_impl:: + _error () const + { + return map_._error () ? error_no_memory : error_none; + } +#endif + + inline serializer_map_impl:: + serializer_map_impl (size_t buckets) + : map_ (buckets, sizeof (serializer_base*)) + { + } + + inline void serializer_map_impl:: + insert (const char* type_id, serializer_base& s) + { + serializer_base* tmp = &s; + map_.insert (type_id, &tmp); + } + + inline void serializer_map_impl:: + insert (serializer_base& s) + { + insert (s._dynamic_type (), s); + } + + inline serializer_base* serializer_map_impl:: + find (const void* type_id) const + { + if (type_id) + { + const void* p = map_.find (static_cast<const char*> (type_id)); + return p ? *static_cast<serializer_base* const*> (p) : 0; + } + return 0; + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/any-type.hxx b/libxsde/xsde/cxx/serializer/non-validating/any-type.hxx new file mode 100644 index 0000000..c01b54e --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/any-type.hxx @@ -0,0 +1,43 @@ +// file : xsde/cxx/serializer/non-validating/any-type.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_NON_VALIDATING_ANY_TYPE_HXX +#define XSDE_CXX_SERIALIZER_NON_VALIDATING_ANY_TYPE_HXX + +#include <xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + // any_type + // +#ifdef XSDE_REUSE_STYLE_MIXIN + struct any_type_simpl: virtual any_type_sskel +#else + struct any_type_simpl: any_type_sskel +#endif + { + }; + + // any_simple_type + // +#ifdef XSDE_REUSE_STYLE_MIXIN + struct any_simple_type_simpl: virtual any_simple_type_sskel +#else + struct any_simple_type_simpl: any_simple_type_sskel +#endif + { + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_NON_VALIDATING_ANY_TYPE_HXX diff --git a/libxsde/xsde/cxx/serializer/non-validating/base64-binary.cxx b/libxsde/xsde/cxx/serializer/non-validating/base64-binary.cxx new file mode 100644 index 0000000..51d1b97 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/base64-binary.cxx @@ -0,0 +1,166 @@ +// file : xsde/cxx/serializer/non-validating/base64-binary.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/serializer/non-validating/base64-binary.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + base64_binary_simpl:: + ~base64_binary_simpl () + { + if (free_) + delete const_cast<buffer*> (value_); + } + + void base64_binary_simpl:: + pre (const buffer* value) + { + value_ = value; + } + + static const char base64_tab[] = { + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', + 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', + 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', + 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', + 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', + 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', + '8', '9', '+', '/', '\0' + }; + + inline void + split_1 (char b, unsigned char& b1, unsigned char& b2) + { + unsigned char ub = static_cast<unsigned char> (b); + b1 = ub >> 2; + b2 = (ub & 0x3) << 4; + } + + inline void + split_2 (char b, unsigned char& b2, unsigned char& b3) + { + unsigned char ub = static_cast<unsigned char> (b); + b2 |= ub >> 4; + b3 = (ub & 0x0F) << 2; + } + + inline void + split_3 (char b, unsigned char& b3, unsigned char& b4) + { + unsigned char ub = static_cast<unsigned char> (b); + b3 |= ub >> 6; + b4 = ( ub & 0x3F ); + } + + void base64_binary_simpl:: + _serialize_content () + { + // Maximum 76 characters per line, 76/4 = 19 + // + const size_t quads_per_line = 19; + char buf[quads_per_line * 4 + 1]; + + if (size_t size = value_->size ()) + { + const char* data = value_->data (); + size_t quads = (size + 2) / 3; + + // Process all quadruplets except the last, one line at a time. + // + size_t i = 0; + size_t j = 0; + unsigned char b1, b2, b3, b4; + + for (; j < (quads - 1);) + { + for (; i < quads_per_line && j < (quads - 1); ++i, ++j) + { + split_1 (*data++, b1, b2); + split_2 (*data++, b2, b3); + split_3 (*data++, b3, b4); + + buf[i * 4] = base64_tab[b1]; + buf[i * 4 + 1] = base64_tab[b2]; + buf[i * 4 + 2] = base64_tab[b3]; + buf[i * 4 + 3] = base64_tab[b4]; + } + + if (i == quads_per_line) + { + buf[i * 4] = '\n'; + +#ifdef XSDE_EXCEPTIONS + _characters (buf, i * 4 + 1); +#else + if (!_characters (buf, i * 4 + 1)) + break; +#endif + i = 0; + } + } + +#ifndef XSDE_EXCEPTIONS + if (j == (quads - 1)) + { +#endif + // Process last quadruplet. The first byte is always present. + // + split_1 (*data++, b1, b2); + buf[i * 4] = base64_tab[b1]; + + if (data != value_->end ()) + { + // Second byte is present. + // + split_2 (*data++, b2, b3); + buf[i * 4 + 1] = base64_tab[b2]; + + if(data != value_->end ()) + { + // Third byte is present. + // + split_3 (*data++, b3, b4); + buf[i * 4 + 2] = base64_tab[b3]; + buf[i * 4 + 3] = base64_tab[b4]; + } + else + { + buf[i * 4 + 2] = base64_tab[b3]; + buf[i * 4 + 3] = '='; + } + } + else + { + buf[i * 4 + 1] = base64_tab[b2]; + buf[i * 4 + 2] = '='; + buf[i * 4 + 3] = '='; + } + + i++; + + buf[i * 4] = '\n'; + _characters (buf, i * 4 + 1); + +#ifndef XSDE_EXCEPTIONS + } +#endif + } + + if (free_) + { + delete const_cast<buffer*> (value_); + value_ = 0; + } + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/base64-binary.hxx b/libxsde/xsde/cxx/serializer/non-validating/base64-binary.hxx new file mode 100644 index 0000000..de4d914 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/base64-binary.hxx @@ -0,0 +1,47 @@ +// file : xsde/cxx/serializer/non-validating/base64-binary.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_NON_VALIDATING_BASE64_BINARY_HXX +#define XSDE_CXX_SERIALIZER_NON_VALIDATING_BASE64_BINARY_HXX + +#include <xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct base64_binary_simpl: virtual base64_binary_sskel +#else + struct base64_binary_simpl: base64_binary_sskel +#endif + { + virtual + ~base64_binary_simpl (); + + base64_binary_simpl (bool free = false); + + virtual void + pre (const buffer*); + + virtual void + _serialize_content (); + + protected: + bool free_; + const buffer* value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/non-validating/base64-binary.ixx> + +#endif // XSDE_CXX_SERIALIZER_NON_VALIDATING_BASE64_BINARY_HXX diff --git a/libxsde/xsde/cxx/serializer/non-validating/base64-binary.ixx b/libxsde/xsde/cxx/serializer/non-validating/base64-binary.ixx new file mode 100644 index 0000000..59a10d6 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/base64-binary.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/non-validating/base64-binary.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + inline base64_binary_simpl:: + base64_binary_simpl (bool free) + : free_ (free), value_ (0) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/boolean.cxx b/libxsde/xsde/cxx/serializer/non-validating/boolean.cxx new file mode 100644 index 0000000..d505d63 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/boolean.cxx @@ -0,0 +1,30 @@ +// file : xsde/cxx/serializer/non-validating/boolean.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/serializer/non-validating/boolean.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + void boolean_simpl:: + pre (bool value) + { + value_ = value; + } + + void boolean_simpl:: + _serialize_content () + { + _characters ((value_ ? "true" : "false"), (value_ ? 4 : 5)); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/boolean.hxx b/libxsde/xsde/cxx/serializer/non-validating/boolean.hxx new file mode 100644 index 0000000..5edcdaa --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/boolean.hxx @@ -0,0 +1,39 @@ +// file : xsde/cxx/serializer/non-validating/boolean.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_NON_VALIDATING_BOOLEAN_HXX +#define XSDE_CXX_SERIALIZER_NON_VALIDATING_BOOLEAN_HXX + +#include <xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct boolean_simpl: virtual boolean_sskel +#else + struct boolean_simpl: boolean_sskel +#endif + { + virtual void + pre (bool); + + virtual void + _serialize_content (); + + protected: + bool value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_NON_VALIDATING_BOOLEAN_HXX diff --git a/libxsde/xsde/cxx/serializer/non-validating/byte.cxx b/libxsde/xsde/cxx/serializer/non-validating/byte.cxx new file mode 100644 index 0000000..200d4ab --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/byte.cxx @@ -0,0 +1,43 @@ +// file : xsde/cxx/serializer/non-validating/byte.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/non-validating/byte.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + void byte_simpl:: + pre (signed char value) + { + value_ = value; + } + + void byte_simpl:: + _serialize_content () + { + // We only need strlen("-128") + 1 characters to hold all + // representations of signed byte. + // + char str[5]; + +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 5, "%d", value_); +#else + int n = sprintf (str, "%d", value_); +#endif + if (n > 0 && n < 5) + _characters (str, static_cast<size_t> (n)); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/byte.hxx b/libxsde/xsde/cxx/serializer/non-validating/byte.hxx new file mode 100644 index 0000000..093adb4 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/byte.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/non-validating/byte.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_NON_VALIDATING_BYTE_HXX +#define XSDE_CXX_SERIALIZER_NON_VALIDATING_BYTE_HXX + +#include <xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + // 8-bit signed integer + // +#ifdef XSDE_REUSE_STYLE_MIXIN + struct byte_simpl: virtual byte_sskel +#else + struct byte_simpl: byte_sskel +#endif + { + virtual void + pre (signed char); + + virtual void + _serialize_content (); + + protected: + signed char value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_NON_VALIDATING_BYTE_HXX diff --git a/libxsde/xsde/cxx/serializer/non-validating/date-time.cxx b/libxsde/xsde/cxx/serializer/non-validating/date-time.cxx new file mode 100644 index 0000000..fe11566 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/date-time.cxx @@ -0,0 +1,78 @@ +// file : xsde/cxx/serializer/non-validating/date-time.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/non-validating/date-time.hxx> +#include <xsde/cxx/serializer/non-validating/time-zone.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + void date_time_simpl:: + pre (const date_time& value) + { + value_ = value; + } + + void date_time_simpl:: + _serialize_content () + { + // We only need strlen("-2147483649-MM-DDThh:mm:ss.ssssss-hh:mm") + // + 1 characters to hold all representations of date_time. We + // know that the seconds part (represented as double) has + // default precision of 6. + // + char str[40]; + + if (value_.month () <= 12 && + value_.day () <= 31 && + value_.hours () <= 24 && + value_.minutes () <= 59 && + value_.seconds () >= 0.0 && + value_.seconds () < 60.0) + { +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 34, "%.4d-%.2u-%.2uT%.2u:%.2u:%09f", + value_.year (), value_.month (), value_.day (), + value_.hours (), value_.minutes (), + value_.seconds ()); +#else + int n = sprintf (str, "%.4d-%.2u-%.2uT%.2u:%.2u:%09f", + value_.year (), value_.month (), value_.day (), + value_.hours (), value_.minutes (), + value_.seconds ()); +#endif + if (n > 0 && n < 34) + { + // Remove trailing '0' and '.' if necessary. + // + while (str[n - 1] == '0') + n--; + + if (str[n - 1] == '.') + n--; + + if (value_.zone_present ()) + { + if (int z = bits::serialize_time_zone (str + n, value_)) + n += z; + else + return; + } + + _characters (str, static_cast<size_t> (n)); + } + } + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/date-time.hxx b/libxsde/xsde/cxx/serializer/non-validating/date-time.hxx new file mode 100644 index 0000000..e239564 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/date-time.hxx @@ -0,0 +1,43 @@ +// file : xsde/cxx/serializer/non-validating/date-time.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_NON_VALIDATING_DATE_TIME_HXX +#define XSDE_CXX_SERIALIZER_NON_VALIDATING_DATE_TIME_HXX + +#include <xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct date_time_simpl: virtual date_time_sskel +#else + struct date_time_simpl: date_time_sskel +#endif + { + date_time_simpl (); + + virtual void + pre (const date_time&); + + virtual void + _serialize_content (); + + protected: + date_time value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/non-validating/date-time.ixx> + +#endif // XSDE_CXX_SERIALIZER_NON_VALIDATING_DATE_TIME_HXX diff --git a/libxsde/xsde/cxx/serializer/non-validating/date-time.ixx b/libxsde/xsde/cxx/serializer/non-validating/date-time.ixx new file mode 100644 index 0000000..e300c03 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/date-time.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/non-validating/date-time.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + inline date_time_simpl:: + date_time_simpl () + : value_ (1, 0, 0, 0, 0, 0.0) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/date.cxx b/libxsde/xsde/cxx/serializer/non-validating/date.cxx new file mode 100644 index 0000000..2fa6069 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/date.cxx @@ -0,0 +1,59 @@ +// file : xsde/cxx/serializer/non-validating/date.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/non-validating/date.hxx> +#include <xsde/cxx/serializer/non-validating/time-zone.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + void date_simpl:: + pre (const date& value) + { + value_ = value; + } + + void date_simpl:: + _serialize_content () + { + // We only need strlen("-2147483649-MM-DD+hh:mm") + 1 characters to + // hold all representations of date. + // + char str[24]; + + if (value_.month () < 13 && value_.day () < 32) + { +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 18, "%.4d-%.2u-%.2u", + value_.year (), value_.month (), value_.day ()); +#else + int n = sprintf (str, "%.4d-%.2u-%.2u", + value_.year (), value_.month (), value_.day ()); +#endif + if (n > 0 && n < 18) + { + if (value_.zone_present ()) + { + if (int z = bits::serialize_time_zone (str + n, value_)) + n += z; + else + return; + } + + _characters (str, static_cast<size_t> (n)); + } + } + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/date.hxx b/libxsde/xsde/cxx/serializer/non-validating/date.hxx new file mode 100644 index 0000000..9fb0f40 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/date.hxx @@ -0,0 +1,43 @@ +// file : xsde/cxx/serializer/non-validating/date.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_NON_VALIDATING_DATE_HXX +#define XSDE_CXX_SERIALIZER_NON_VALIDATING_DATE_HXX + +#include <xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct date_simpl: virtual date_sskel +#else + struct date_simpl: date_sskel +#endif + { + date_simpl (); + + virtual void + pre (const date&); + + virtual void + _serialize_content (); + + protected: + date value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/non-validating/date.ixx> + +#endif // XSDE_CXX_SERIALIZER_NON_VALIDATING_DATE_HXX diff --git a/libxsde/xsde/cxx/serializer/non-validating/date.ixx b/libxsde/xsde/cxx/serializer/non-validating/date.ixx new file mode 100644 index 0000000..c89cea4 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/date.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/non-validating/date.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + inline date_simpl:: + date_simpl () + : value_ (1, 1, 1) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/decimal.cxx b/libxsde/xsde/cxx/serializer/non-validating/decimal.cxx new file mode 100644 index 0000000..dd55ab0 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/decimal.cxx @@ -0,0 +1,54 @@ +// file : xsde/cxx/serializer/non-validating/decimal.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/non-validating/decimal.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + void decimal_simpl:: + pre (double value) + { + value_ = value; + } + + void decimal_simpl:: + _serialize_content () + { + // Assume double values cannot be longer than 127 characters. + // + char str[128]; + +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 128, "%.*f", + static_cast<int> (precision_), value_); +#else + int n = sprintf (str, "%.*f", + static_cast<int> (precision_), value_); +#endif + if (n > 0 && n < 128) + { + // Remove trailing '0' and '.' if necessary. + // + while (str[n - 1] == '0') + n--; + + if (str[n - 1] == '.') + n--; + + _characters (str, static_cast<size_t> (n)); + } + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/decimal.hxx b/libxsde/xsde/cxx/serializer/non-validating/decimal.hxx new file mode 100644 index 0000000..b0155b3 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/decimal.hxx @@ -0,0 +1,50 @@ +// file : xsde/cxx/serializer/non-validating/decimal.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_NON_VALIDATING_DECIMAL_HXX +#define XSDE_CXX_SERIALIZER_NON_VALIDATING_DECIMAL_HXX + +#include <float.h> + +#include <xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct decimal_simpl: virtual decimal_sskel +#else + struct decimal_simpl: decimal_sskel +#endif + { +#ifdef DBL_DIG + decimal_simpl (unsigned int precision = DBL_DIG); +#else + decimal_simpl (unsigned int precision = 15) +#endif + + virtual void + pre (double); + + virtual void + _serialize_content (); + + protected: + unsigned int precision_; + double value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/non-validating/decimal.ixx> + +#endif // XSDE_CXX_SERIALIZER_NON_VALIDATING_DECIMAL_HXX diff --git a/libxsde/xsde/cxx/serializer/non-validating/decimal.ixx b/libxsde/xsde/cxx/serializer/non-validating/decimal.ixx new file mode 100644 index 0000000..af3ab38 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/decimal.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/non-validating/decimal.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + inline decimal_simpl:: + decimal_simpl (unsigned int p) + : precision_ (p) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/double.cxx b/libxsde/xsde/cxx/serializer/non-validating/double.cxx new file mode 100644 index 0000000..1f8f459 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/double.cxx @@ -0,0 +1,103 @@ +// file : xsde/cxx/serializer/non-validating/double.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/non-validating/double.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + void double_simpl:: + pre (double value) + { + value_ = value; + } + + void double_simpl:: + _serialize_content () + { + // Assume double values cannot be longer than 127 characters. + // + char str[128]; + + const char* fmt = 0; + + switch (notation_) + { + case notation_auto: + { + fmt = "%.*g"; + break; + } + case notation_fixed: + { + fmt = "%.*f"; + break; + } + case notation_scientific: + { + fmt = "%.*e"; + break; + } + } + +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 128, fmt, precision_, value_); +#else + int n = sprintf (str, fmt, precision_, value_); +#endif + if (n > 0 && n < 128) + { + if (str[0] == '-') + { + if (str[1] == 'n' && str[2] == 'a' && str[3] == 'n') + { + _characters ("NaN", 3); + return; + } + else if (str[1] == 'i' && str[2] == 'n' && str[3] == 'f') + { + _characters ("-INF", 4); + return; + } + } + else + { + if (str[0] == 'n' && str[1] == 'a' && str[2] == 'n') + { + _characters ("NaN", 3); + return; + } + else if (str[0] == 'i' && str[1] == 'n' && str[2] == 'f') + { + _characters ("INF", 3); + return; + } + } + + if (notation_ == notation_fixed) + { + // Remove trailing '0' and '.' if necessary. + // + while (str[n - 1] == '0') + n--; + + if (str[n - 1] == '.') + n--; + } + + _characters (str, static_cast<size_t> (n)); + } + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/double.hxx b/libxsde/xsde/cxx/serializer/non-validating/double.hxx new file mode 100644 index 0000000..a79c144 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/double.hxx @@ -0,0 +1,60 @@ +// file : xsde/cxx/serializer/non-validating/double.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_NON_VALIDATING_DOUBLE_HXX +#define XSDE_CXX_SERIALIZER_NON_VALIDATING_DOUBLE_HXX + +#include <float.h> + +#include <xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct double_simpl: virtual double_sskel +#else + struct double_simpl: double_sskel +#endif + { + enum notation + { + notation_auto, + notation_fixed, + notation_scientific + }; + +#ifdef DBL_DIG + double_simpl (notation = notation_auto, + unsigned int precision = DBL_DIG); +#else + double_simpl (notation = notation_auto, + unsigned int precision = 15) +#endif + + virtual void + pre (double); + + virtual void + _serialize_content (); + + protected: + notation notation_; + unsigned int precision_; + double value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/non-validating/double.ixx> + +#endif // XSDE_CXX_SERIALIZER_NON_VALIDATING_DOUBLE_HXX diff --git a/libxsde/xsde/cxx/serializer/non-validating/double.ixx b/libxsde/xsde/cxx/serializer/non-validating/double.ixx new file mode 100644 index 0000000..36cc319 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/double.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/non-validating/double.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + inline double_simpl:: + double_simpl (notation n, unsigned int p) + : notation_ (n), precision_ (p) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/duration.cxx b/libxsde/xsde/cxx/serializer/non-validating/duration.cxx new file mode 100644 index 0000000..1174af7 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/duration.cxx @@ -0,0 +1,171 @@ +// file : xsde/cxx/serializer/non-validating/duration.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/non-validating/duration.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + void duration_simpl:: + pre (const duration& value) + { + value_ = value; + } + + void duration_simpl:: + _serialize_content () + { + // duration := -PnYnMnDTnHnMnS + // + // The years, months, days, hours, and minutes components are + // represented as 32 unsigned integers with maximum string + // representation being strlen ("4294967295") = 10. + // + // We assume that the seconds part (double) cannot be longer + // than 128 chars. + // + // The total representation thus cannot exceed 10*5 + 128 + + // 9 + 1 = 188 characters. + // + char str[188]; + char* p = str; + + if (value_.negative ()) + *p++ = '-'; + + *p++ = 'P'; + + // years + // + // In case it is 0-duration, use the years field to handle + // this case. + // + if (value_.years () != 0 || + (value_.months () == 0 && + value_.days () == 0 && + value_.hours () == 0 && + value_.minutes () == 0 && + value_.seconds () == 0.0)) + { +#ifdef XSDE_SNPRINTF + int n = snprintf (p, 11, "%u", value_.years ()); +#else + int n = sprintf (p, "%u", value_.years ()); +#endif + if (n < 0 || n >= 11) + return; + + p += n; + *p++ = 'Y'; + } + + // months + // + if (value_.months () != 0) + { +#ifdef XSDE_SNPRINTF + int n = snprintf (p, 11, "%u", value_.months ()); +#else + int n = sprintf (p, "%u", value_.months ()); +#endif + if (n < 0 || n >= 11) + return; + + p += n; + *p++ = 'M'; + } + + // days + // + if (value_.days () != 0) + { +#ifdef XSDE_SNPRINTF + int n = snprintf (p, 11, "%u", value_.days ()); +#else + int n = sprintf (p, "%u", value_.days ()); +#endif + if (n < 0 || n >= 11) + return; + + p += n; + *p++ = 'D'; + } + + // Figure out if we need the 'T' delimiter. + // + if (value_.hours () != 0 || + value_.minutes () != 0 || + value_.seconds () != 0.0) + *p++ = 'T'; + + // hours + // + if (value_.hours () != 0) + { +#ifdef XSDE_SNPRINTF + int n = snprintf (p, 11, "%u", value_.hours ()); +#else + int n = sprintf (p, "%u", value_.hours ()); +#endif + if (n < 0 || n >= 11) + return; + + p += n; + *p++ = 'H'; + } + + // minutes + // + if (value_.minutes () != 0) + { +#ifdef XSDE_SNPRINTF + int n = snprintf (p, 11, "%u", value_.minutes ()); +#else + int n = sprintf (p, "%u", value_.minutes ()); +#endif + if (n < 0 || n >= 11) + return; + + p += n; + *p++ = 'M'; + } + + // seconds + // + if (value_.seconds () > 0.0) + { +#ifdef XSDE_SNPRINTF + int n = snprintf (p, 128, "%f", value_.seconds ()); +#else + int n = sprintf (p, "%f", value_.seconds ()); +#endif + if (n < 0 || n >= 128) + return; + + // Remove trailing '0' and '.' if necessary. + // + while (p[n - 1] == '0') + n--; + + if (p[n - 1] == '.') + n--; + + p += n; + *p++ = 'S'; + } + + _characters (str, static_cast<size_t> (p - str)); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/duration.hxx b/libxsde/xsde/cxx/serializer/non-validating/duration.hxx new file mode 100644 index 0000000..88530f4 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/duration.hxx @@ -0,0 +1,43 @@ +// file : xsde/cxx/serializer/non-validating/duration.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_NON_VALIDATING_DURATION_HXX +#define XSDE_CXX_SERIALIZER_NON_VALIDATING_DURATION_HXX + +#include <xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct duration_simpl: virtual duration_sskel +#else + struct duration_simpl: duration_sskel +#endif + { + duration_simpl (); + + virtual void + pre (const duration&); + + virtual void + _serialize_content (); + + protected: + duration value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/non-validating/duration.ixx> + +#endif // XSDE_CXX_SERIALIZER_NON_VALIDATING_DURATION_HXX diff --git a/libxsde/xsde/cxx/serializer/non-validating/duration.ixx b/libxsde/xsde/cxx/serializer/non-validating/duration.ixx new file mode 100644 index 0000000..10d2287 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/duration.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/non-validating/duration.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + inline duration_simpl:: + duration_simpl () + : value_ (false, 1, 0, 0, 0, 0, 0.0) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/float.cxx b/libxsde/xsde/cxx/serializer/non-validating/float.cxx new file mode 100644 index 0000000..3af6e76 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/float.cxx @@ -0,0 +1,103 @@ +// file : xsde/cxx/serializer/non-validating/float.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/non-validating/float.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + void float_simpl:: + pre (float value) + { + value_ = value; + } + + void float_simpl:: + _serialize_content () + { + // Assume float values cannot be longer than 127 characters. + // + char str[128]; + + const char* fmt = 0; + + switch (notation_) + { + case notation_auto: + { + fmt = "%.*g"; + break; + } + case notation_fixed: + { + fmt = "%.*f"; + break; + } + case notation_scientific: + { + fmt = "%.*e"; + break; + } + } + +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 128, fmt, precision_, value_); +#else + int n = sprintf (str, fmt, precision_, value_); +#endif + if (n > 0 && n < 128) + { + if (str[0] == '-') + { + if (str[1] == 'n' && str[2] == 'a' && str[3] == 'n') + { + _characters ("NaN", 3); + return; + } + else if (str[1] == 'i' && str[2] == 'n' && str[3] == 'f') + { + _characters ("-INF", 4); + return; + } + } + else + { + if (str[0] == 'n' && str[1] == 'a' && str[2] == 'n') + { + _characters ("NaN", 3); + return; + } + else if (str[0] == 'i' && str[1] == 'n' && str[2] == 'f') + { + _characters ("INF", 3); + return; + } + } + + if (notation_ == notation_fixed) + { + // Remove trailing '0' and '.' if necessary. + // + while (str[n - 1] == '0') + n--; + + if (str[n - 1] == '.') + n--; + } + + _characters (str, static_cast<size_t> (n)); + } + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/float.hxx b/libxsde/xsde/cxx/serializer/non-validating/float.hxx new file mode 100644 index 0000000..d3da48f --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/float.hxx @@ -0,0 +1,60 @@ +// file : xsde/cxx/serializer/non-validating/float.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_NON_VALIDATING_FLOAT_HXX +#define XSDE_CXX_SERIALIZER_NON_VALIDATING_FLOAT_HXX + +#include <float.h> + +#include <xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct float_simpl: virtual float_sskel +#else + struct float_simpl: float_sskel +#endif + { + enum notation + { + notation_auto, + notation_fixed, + notation_scientific + }; + +#ifdef FLT_DIG + float_simpl (notation = notation_auto, + unsigned int precision = FLT_DIG); +#else + float_simpl (notation = notation_auto, + unsigned int precision = 6) +#endif + + virtual void + pre (float); + + virtual void + _serialize_content (); + + protected: + notation notation_; + unsigned int precision_; + float value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/non-validating/float.ixx> + +#endif // XSDE_CXX_SERIALIZER_NON_VALIDATING_FLOAT_HXX diff --git a/libxsde/xsde/cxx/serializer/non-validating/float.ixx b/libxsde/xsde/cxx/serializer/non-validating/float.ixx new file mode 100644 index 0000000..192027e --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/float.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/non-validating/float.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + inline float_simpl:: + float_simpl (notation n, unsigned int p) + : notation_ (n), precision_ (p) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/gday.cxx b/libxsde/xsde/cxx/serializer/non-validating/gday.cxx new file mode 100644 index 0000000..5d3a0a3 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/gday.cxx @@ -0,0 +1,57 @@ +// file : xsde/cxx/serializer/non-validating/gday.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/non-validating/gday.hxx> +#include <xsde/cxx/serializer/non-validating/time-zone.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + void gday_simpl:: + pre (const gday& value) + { + value_ = value; + } + + void gday_simpl:: + _serialize_content () + { + // We only need strlen("---DD+hh:mm") + 1 characters to hold all + // representations of gDay. + // + char str[12]; + + if (value_.day () < 32) + { +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 6, "---%.2u", value_.day ()); +#else + int n = sprintf (str, "---%.2u", value_.day ()); +#endif + if (n > 0 && n < 6) + { + if (value_.zone_present ()) + { + if (int z = bits::serialize_time_zone (str + n, value_)) + n += z; + else + return; + } + + _characters (str, static_cast<size_t> (n)); + } + } + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/gday.hxx b/libxsde/xsde/cxx/serializer/non-validating/gday.hxx new file mode 100644 index 0000000..1442664 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/gday.hxx @@ -0,0 +1,43 @@ +// file : xsde/cxx/serializer/non-validating/gday.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_NON_VALIDATING_GDAY_HXX +#define XSDE_CXX_SERIALIZER_NON_VALIDATING_GDAY_HXX + +#include <xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct gday_simpl: virtual gday_sskel +#else + struct gday_simpl: gday_sskel +#endif + { + gday_simpl (); + + virtual void + pre (const gday&); + + virtual void + _serialize_content (); + + protected: + gday value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/non-validating/gday.ixx> + +#endif // XSDE_CXX_SERIALIZER_NON_VALIDATING_GDAY_HXX diff --git a/libxsde/xsde/cxx/serializer/non-validating/gday.ixx b/libxsde/xsde/cxx/serializer/non-validating/gday.ixx new file mode 100644 index 0000000..ba322f6 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/gday.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/non-validating/gday.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + inline gday_simpl:: + gday_simpl () + : value_ (1) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/gmonth-day.cxx b/libxsde/xsde/cxx/serializer/non-validating/gmonth-day.cxx new file mode 100644 index 0000000..cb0bb4f --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/gmonth-day.cxx @@ -0,0 +1,59 @@ +// file : xsde/cxx/serializer/non-validating/gmonth-day.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/non-validating/gmonth-day.hxx> +#include <xsde/cxx/serializer/non-validating/time-zone.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + void gmonth_day_simpl:: + pre (const gmonth_day& value) + { + value_ = value; + } + + void gmonth_day_simpl:: + _serialize_content () + { + // We only need strlen("--MM-DD+hh:mm") + 1 characters to hold all + // representations of gMonthDay. + // + char str[14]; + + if (value_.month () < 13 && value_.day () < 32) + { +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 8, "--%.2u-%.2u", + value_.month (), value_.day ()); +#else + int n = sprintf (str, "--%.2u-%.2u", + value_.month (), value_.day ()); +#endif + if (n > 0 && n < 8) + { + if (value_.zone_present ()) + { + if (int z = bits::serialize_time_zone (str + n, value_)) + n += z; + else + return; + } + + _characters (str, static_cast<size_t> (n)); + } + } + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/gmonth-day.hxx b/libxsde/xsde/cxx/serializer/non-validating/gmonth-day.hxx new file mode 100644 index 0000000..6ba2ccf --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/gmonth-day.hxx @@ -0,0 +1,43 @@ +// file : xsde/cxx/serializer/non-validating/gmonth-day.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_NON_VALIDATING_GMONTH_DAY_HXX +#define XSDE_CXX_SERIALIZER_NON_VALIDATING_GMONTH_DAY_HXX + +#include <xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct gmonth_day_simpl: virtual gmonth_day_sskel +#else + struct gmonth_day_simpl: gmonth_day_sskel +#endif + { + gmonth_day_simpl (); + + virtual void + pre (const gmonth_day&); + + virtual void + _serialize_content (); + + protected: + gmonth_day value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/non-validating/gmonth-day.ixx> + +#endif // XSDE_CXX_SERIALIZER_NON_VALIDATING_GMONTH_DAY_HXX diff --git a/libxsde/xsde/cxx/serializer/non-validating/gmonth-day.ixx b/libxsde/xsde/cxx/serializer/non-validating/gmonth-day.ixx new file mode 100644 index 0000000..864f56c --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/gmonth-day.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/non-validating/gmonth-day.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + inline gmonth_day_simpl:: + gmonth_day_simpl () + : value_ (1, 1) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/gmonth.cxx b/libxsde/xsde/cxx/serializer/non-validating/gmonth.cxx new file mode 100644 index 0000000..09c9739 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/gmonth.cxx @@ -0,0 +1,57 @@ +// file : xsde/cxx/serializer/non-validating/gmonth.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/non-validating/gmonth.hxx> +#include <xsde/cxx/serializer/non-validating/time-zone.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + void gmonth_simpl:: + pre (const gmonth& value) + { + value_ = value; + } + + void gmonth_simpl:: + _serialize_content () + { + // We only need strlen("--MM+hh:mm") + 1 characters to hold all + // representations of gMonth. + // + char str[11]; + + if (value_.month () < 13) + { +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 5, "--%.2u", value_.month ()); +#else + int n = sprintf (str, "--%.2u", value_.month ()); +#endif + if (n > 0 && n < 5) + { + if (value_.zone_present ()) + { + if (int z = bits::serialize_time_zone (str + n, value_)) + n += z; + else + return; + } + + _characters (str, static_cast<size_t> (n)); + } + } + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/gmonth.hxx b/libxsde/xsde/cxx/serializer/non-validating/gmonth.hxx new file mode 100644 index 0000000..5ed6310 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/gmonth.hxx @@ -0,0 +1,43 @@ +// file : xsde/cxx/serializer/non-validating/gmonth.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_NON_VALIDATING_GMONTH_HXX +#define XSDE_CXX_SERIALIZER_NON_VALIDATING_GMONTH_HXX + +#include <xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct gmonth_simpl: virtual gmonth_sskel +#else + struct gmonth_simpl: gmonth_sskel +#endif + { + gmonth_simpl (); + + virtual void + pre (const gmonth&); + + virtual void + _serialize_content (); + + protected: + gmonth value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/non-validating/gmonth.ixx> + +#endif // XSDE_CXX_SERIALIZER_NON_VALIDATING_GMONTH_HXX diff --git a/libxsde/xsde/cxx/serializer/non-validating/gmonth.ixx b/libxsde/xsde/cxx/serializer/non-validating/gmonth.ixx new file mode 100644 index 0000000..c0b98f3 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/gmonth.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/non-validating/gmonth.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + inline gmonth_simpl:: + gmonth_simpl () + : value_ (1) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/gyear-month.cxx b/libxsde/xsde/cxx/serializer/non-validating/gyear-month.cxx new file mode 100644 index 0000000..bbb2794 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/gyear-month.cxx @@ -0,0 +1,59 @@ +// file : xsde/cxx/serializer/non-validating/gyear-month.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/non-validating/gyear-month.hxx> +#include <xsde/cxx/serializer/non-validating/time-zone.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + void gyear_month_simpl:: + pre (const gyear_month& value) + { + value_ = value; + } + + void gyear_month_simpl:: + _serialize_content () + { + // We only need strlen("-2147483649-MM+hh:mm") + 1 characters to + // hold all representations of gYearMonth. + // + char str[21]; + + if (value_.month () < 13) + { +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 15, "%.4d-%.2u", + value_.year (), value_.month ()); +#else + int n = sprintf (str, "%.4d-%.2u", + value_.year (), value_.month ()); +#endif + if (n > 0 && n < 15) + { + if (value_.zone_present ()) + { + if (int z = bits::serialize_time_zone (str + n, value_)) + n += z; + else + return; + } + + _characters (str, static_cast<size_t> (n)); + } + } + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/gyear-month.hxx b/libxsde/xsde/cxx/serializer/non-validating/gyear-month.hxx new file mode 100644 index 0000000..32ee339 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/gyear-month.hxx @@ -0,0 +1,43 @@ +// file : xsde/cxx/serializer/non-validating/gyear-month.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_NON_VALIDATING_GYEAR_MONTH_HXX +#define XSDE_CXX_SERIALIZER_NON_VALIDATING_GYEAR_MONTH_HXX + +#include <xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct gyear_month_simpl: virtual gyear_month_sskel +#else + struct gyear_month_simpl: gyear_month_sskel +#endif + { + gyear_month_simpl (); + + virtual void + pre (const gyear_month&); + + virtual void + _serialize_content (); + + protected: + gyear_month value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/non-validating/gyear-month.ixx> + +#endif // XSDE_CXX_SERIALIZER_NON_VALIDATING_GYEAR_MONTH_HXX diff --git a/libxsde/xsde/cxx/serializer/non-validating/gyear-month.ixx b/libxsde/xsde/cxx/serializer/non-validating/gyear-month.ixx new file mode 100644 index 0000000..f33b7b6 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/gyear-month.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/non-validating/gyear-month.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + inline gyear_month_simpl:: + gyear_month_simpl () + : value_ (1, 1) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/gyear.cxx b/libxsde/xsde/cxx/serializer/non-validating/gyear.cxx new file mode 100644 index 0000000..4d7a796 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/gyear.cxx @@ -0,0 +1,54 @@ +// file : xsde/cxx/serializer/non-validating/gyear.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/non-validating/gyear.hxx> +#include <xsde/cxx/serializer/non-validating/time-zone.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + void gyear_simpl:: + pre (const gyear& value) + { + value_ = value; + } + + void gyear_simpl:: + _serialize_content () + { + // We only need strlen("-2147483649+hh:mm") + 1 characters to + // hold all representations of gYear. + // + char str[18]; + +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 12, "%.4d", value_.year ()); +#else + int n = sprintf (str, "%.4d", value_.year ()); +#endif + if (n > 0 && n < 12) + { + if (value_.zone_present ()) + { + if (int z = bits::serialize_time_zone (str + n, value_)) + n += z; + else + return; + } + + _characters (str, static_cast<size_t> (n)); + } + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/gyear.hxx b/libxsde/xsde/cxx/serializer/non-validating/gyear.hxx new file mode 100644 index 0000000..ea38751 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/gyear.hxx @@ -0,0 +1,43 @@ +// file : xsde/cxx/serializer/non-validating/gyear.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_NON_VALIDATING_GYEAR_HXX +#define XSDE_CXX_SERIALIZER_NON_VALIDATING_GYEAR_HXX + +#include <xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct gyear_simpl: virtual gyear_sskel +#else + struct gyear_simpl: gyear_sskel +#endif + { + gyear_simpl (); + + virtual void + pre (const gyear&); + + virtual void + _serialize_content (); + + protected: + gyear value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/non-validating/gyear.ixx> + +#endif // XSDE_CXX_SERIALIZER_NON_VALIDATING_GYEAR_HXX diff --git a/libxsde/xsde/cxx/serializer/non-validating/gyear.ixx b/libxsde/xsde/cxx/serializer/non-validating/gyear.ixx new file mode 100644 index 0000000..f1db195 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/gyear.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/non-validating/gyear.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + inline gyear_simpl:: + gyear_simpl () + : value_ (1) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/hex-binary.cxx b/libxsde/xsde/cxx/serializer/non-validating/hex-binary.cxx new file mode 100644 index 0000000..f341ff2 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/hex-binary.cxx @@ -0,0 +1,70 @@ +// file : xsde/cxx/serializer/non-validating/hex-binary.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/serializer/non-validating/hex-binary.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + hex_binary_simpl:: + ~hex_binary_simpl () + { + if (free_) + delete const_cast<buffer*> (value_); + } + + void hex_binary_simpl:: + pre (const buffer* value) + { + value_ = value; + } + + static const char hex_tab[] = "0123456789ABCDEF"; + + void hex_binary_simpl:: + _serialize_content () + { + char buf[512]; + + size_t size = value_->size (); + const char* data = value_->data (); + + // Covert the data in 256-byte chunks. + // + for (size_t j = 0; j < size;) + { + size_t i = 0; + + for (; i < 512 && j < size; ++j) + { + unsigned char byte = static_cast<unsigned char> (data[j]); + + buf[i++] = hex_tab[byte >> 4]; + buf[i++] = hex_tab[byte & 0x0F]; + } + +#ifdef XSDE_EXCEPTIONS + _characters (buf, i); +#else + if (!_characters (buf, i)) + break; +#endif + } + + if (free_) + { + delete const_cast<buffer*> (value_); + value_ = 0; + } + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/hex-binary.hxx b/libxsde/xsde/cxx/serializer/non-validating/hex-binary.hxx new file mode 100644 index 0000000..eb10879 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/hex-binary.hxx @@ -0,0 +1,47 @@ +// file : xsde/cxx/serializer/non-validating/hex-binary.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_NON_VALIDATING_HEX_BINARY_HXX +#define XSDE_CXX_SERIALIZER_NON_VALIDATING_HEX_BINARY_HXX + +#include <xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct hex_binary_simpl: virtual hex_binary_sskel +#else + struct hex_binary_simpl: hex_binary_sskel +#endif + { + virtual + ~hex_binary_simpl (); + + hex_binary_simpl (bool free = false); + + virtual void + pre (const buffer*); + + virtual void + _serialize_content (); + + protected: + bool free_; + const buffer* value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/non-validating/hex-binary.ixx> + +#endif // XSDE_CXX_SERIALIZER_NON_VALIDATING_HEX_BINARY_HXX diff --git a/libxsde/xsde/cxx/serializer/non-validating/hex-binary.ixx b/libxsde/xsde/cxx/serializer/non-validating/hex-binary.ixx new file mode 100644 index 0000000..3305b15 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/hex-binary.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/non-validating/hex-binary.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + inline hex_binary_simpl:: + hex_binary_simpl (bool free) + : free_ (free), value_ (0) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/id-stl.cxx b/libxsde/xsde/cxx/serializer/non-validating/id-stl.cxx new file mode 100644 index 0000000..ed63192 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/id-stl.cxx @@ -0,0 +1,35 @@ +// file : xsde/cxx/serializer/non-validating/id-stl.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/serializer/non-validating/id-stl.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + void id_simpl:: + pre (const std::string& value) + { + value_ = value; + } + + void id_simpl:: + _serialize_content () + { + // Make sure we don't hold any references to the string. + // + std::string tmp; + tmp.swap (value_); + + _characters (tmp.c_str (), tmp.size ()); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/id-stl.hxx b/libxsde/xsde/cxx/serializer/non-validating/id-stl.hxx new file mode 100644 index 0000000..a615151 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/id-stl.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/non-validating/id-stl.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_NON_VALIDATING_ID_STL_HXX +#define XSDE_CXX_SERIALIZER_NON_VALIDATING_ID_STL_HXX + +#include <string> + +#include <xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct id_simpl: virtual id_sskel +#else + struct id_simpl: id_sskel +#endif + { + virtual void + pre (const std::string&); + + virtual void + _serialize_content (); + + protected: + std::string value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_NON_VALIDATING_ID_STL_HXX diff --git a/libxsde/xsde/cxx/serializer/non-validating/id.cxx b/libxsde/xsde/cxx/serializer/non-validating/id.cxx new file mode 100644 index 0000000..ab75ad5 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/id.cxx @@ -0,0 +1,43 @@ +// file : xsde/cxx/serializer/non-validating/id.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/serializer/non-validating/id.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + id_simpl:: + ~id_simpl () + { + if (free_) + delete[] const_cast<char*> (value_); + } + + void id_simpl:: + pre (const char* value) + { + value_ = value; + } + + void id_simpl:: + _serialize_content () + { + _characters (value_); + + if (free_) + { + delete[] const_cast<char*> (value_); + value_ = 0; + } + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/id.hxx b/libxsde/xsde/cxx/serializer/non-validating/id.hxx new file mode 100644 index 0000000..2c0563c --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/id.hxx @@ -0,0 +1,47 @@ +// file : xsde/cxx/serializer/non-validating/id.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_NON_VALIDATING_ID_HXX +#define XSDE_CXX_SERIALIZER_NON_VALIDATING_ID_HXX + +#include <xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct id_simpl: virtual id_sskel +#else + struct id_simpl: id_sskel +#endif + { + virtual + ~id_simpl (); + + id_simpl (bool free = false); + + virtual void + pre (const char*); + + virtual void + _serialize_content (); + + protected: + bool free_; + const char* value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/non-validating/id.ixx> + +#endif // XSDE_CXX_SERIALIZER_NON_VALIDATING_ID_HXX diff --git a/libxsde/xsde/cxx/serializer/non-validating/id.ixx b/libxsde/xsde/cxx/serializer/non-validating/id.ixx new file mode 100644 index 0000000..22e4201 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/id.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/non-validating/id.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + inline id_simpl:: + id_simpl (bool free) + : free_ (free) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/idref-stl.cxx b/libxsde/xsde/cxx/serializer/non-validating/idref-stl.cxx new file mode 100644 index 0000000..2b128e7 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/idref-stl.cxx @@ -0,0 +1,35 @@ +// file : xsde/cxx/serializer/non-validating/idref-stl.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/serializer/non-validating/idref-stl.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + void idref_simpl:: + pre (const std::string& value) + { + value_ = value; + } + + void idref_simpl:: + _serialize_content () + { + // Make sure we don't hold any references to the string. + // + std::string tmp; + tmp.swap (value_); + + _characters (tmp.c_str (), tmp.size ()); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/idref-stl.hxx b/libxsde/xsde/cxx/serializer/non-validating/idref-stl.hxx new file mode 100644 index 0000000..1fc6d08 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/idref-stl.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/non-validating/idref-stl.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_NON_VALIDATING_IDREF_STL_HXX +#define XSDE_CXX_SERIALIZER_NON_VALIDATING_IDREF_STL_HXX + +#include <string> + +#include <xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct idref_simpl: virtual idref_sskel +#else + struct idref_simpl: idref_sskel +#endif + { + virtual void + pre (const std::string&); + + virtual void + _serialize_content (); + + protected: + std::string value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_NON_VALIDATING_IDREF_STL_HXX diff --git a/libxsde/xsde/cxx/serializer/non-validating/idref.cxx b/libxsde/xsde/cxx/serializer/non-validating/idref.cxx new file mode 100644 index 0000000..527beb5 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/idref.cxx @@ -0,0 +1,43 @@ +// file : xsde/cxx/serializer/non-validating/idref.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/serializer/non-validating/idref.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + idref_simpl:: + ~idref_simpl () + { + if (free_) + delete[] const_cast<char*> (value_); + } + + void idref_simpl:: + pre (const char* value) + { + value_ = value; + } + + void idref_simpl:: + _serialize_content () + { + _characters (value_); + + if (free_) + { + delete[] const_cast<char*> (value_); + value_ = 0; + } + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/idref.hxx b/libxsde/xsde/cxx/serializer/non-validating/idref.hxx new file mode 100644 index 0000000..295c701 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/idref.hxx @@ -0,0 +1,47 @@ +// file : xsde/cxx/serializer/non-validating/idref.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_NON_VALIDATING_IDREF_HXX +#define XSDE_CXX_SERIALIZER_NON_VALIDATING_IDREF_HXX + +#include <xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct idref_simpl: virtual idref_sskel +#else + struct idref_simpl: idref_sskel +#endif + { + virtual + ~idref_simpl (); + + idref_simpl (bool free = false); + + virtual void + pre (const char*); + + virtual void + _serialize_content (); + + protected: + bool free_; + const char* value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/non-validating/idref.ixx> + +#endif // XSDE_CXX_SERIALIZER_NON_VALIDATING_IDREF_HXX diff --git a/libxsde/xsde/cxx/serializer/non-validating/idref.ixx b/libxsde/xsde/cxx/serializer/non-validating/idref.ixx new file mode 100644 index 0000000..e558f2f --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/idref.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/non-validating/idref.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + inline idref_simpl:: + idref_simpl (bool free) + : free_ (free) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/idrefs-stl.cxx b/libxsde/xsde/cxx/serializer/non-validating/idrefs-stl.cxx new file mode 100644 index 0000000..75db514 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/idrefs-stl.cxx @@ -0,0 +1,108 @@ +// file : xsde/cxx/serializer/non-validating/idrefs-stl.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/serializer/non-validating/idrefs-stl.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + idrefs_simpl:: + ~idrefs_simpl () + { + if (free_) + delete const_cast<string_sequence*> (value_); + } + + void idrefs_simpl:: + pre (const string_sequence* value) + { + value_ = value; + } + + void idrefs_simpl:: + _serialize_content () + { + bool first = true; + context& ctx = _context (); + + for (string_sequence::const_iterator i (value_->begin ()), + e (value_->end ()); i != e; ++i) + { +#ifdef XSDE_EXCEPTIONS + serializer_.pre (*i); + + if (!first) + _characters (" ", 1); + else + first = false; + + serializer_._pre_impl (ctx); + serializer_._serialize_content (); + serializer_._post_impl (); + serializer_.post (); +#else + serializer_.pre (*i); + + if (serializer_._error_type ()) + serializer_._copy_error (ctx); + + if (ctx.error_type ()) + break; + + if (!first) + { + if (!_characters (" ", 1)) + break; + } + else + first = false; + + serializer_._pre_impl (ctx); + + if (ctx.error_type ()) + break; + + serializer_._serialize_content (); + + if (ctx.error_type ()) + break; + + serializer_._post_impl (); + + if (ctx.error_type ()) + break; + + serializer_.post (); + + if (serializer_._error_type ()) + serializer_._copy_error (ctx); + + if (ctx.error_type ()) + break; +#endif + } + + if (free_) + { + delete const_cast<string_sequence*> (value_); + value_ = 0; + } + } + + void idrefs_simpl:: + _reset () + { + idrefs_sskel::_reset (); + serializer_._reset (); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/idrefs-stl.hxx b/libxsde/xsde/cxx/serializer/non-validating/idrefs-stl.hxx new file mode 100644 index 0000000..bb88871 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/idrefs-stl.hxx @@ -0,0 +1,52 @@ +// file : xsde/cxx/serializer/non-validating/idrefs-stl.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_NON_VALIDATING_IDREFS_STL_HXX +#define XSDE_CXX_SERIALIZER_NON_VALIDATING_IDREFS_STL_HXX + +#include <xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx> +#include <xsde/cxx/serializer/non-validating/idref-stl.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct idrefs_simpl: virtual idrefs_sskel +#else + struct idrefs_simpl: idrefs_sskel +#endif + { + virtual + ~idrefs_simpl (); + + idrefs_simpl (bool free = false); + + virtual void + pre (const string_sequence*); + + virtual void + _serialize_content (); + + virtual void + _reset (); + + protected: + bool free_; + const string_sequence* value_; + idref_simpl serializer_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/non-validating/idrefs-stl.ixx> + +#endif // XSDE_CXX_SERIALIZER_NON_VALIDATING_IDREFS_STL_HXX diff --git a/libxsde/xsde/cxx/serializer/non-validating/idrefs-stl.ixx b/libxsde/xsde/cxx/serializer/non-validating/idrefs-stl.ixx new file mode 100644 index 0000000..ff15241 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/idrefs-stl.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/non-validating/idrefs-stl.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + inline idrefs_simpl:: + idrefs_simpl (bool free) + : free_ (free), value_ (0) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/idrefs.cxx b/libxsde/xsde/cxx/serializer/non-validating/idrefs.cxx new file mode 100644 index 0000000..a795453 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/idrefs.cxx @@ -0,0 +1,109 @@ +// file : xsde/cxx/serializer/non-validating/idrefs.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/serializer/non-validating/idrefs.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + idrefs_simpl:: + ~idrefs_simpl () + { + if (free_) + delete const_cast<string_sequence*> (value_); + } + + void idrefs_simpl:: + pre (const string_sequence* value) + { + value_ = value; + } + + void idrefs_simpl:: + _serialize_content () + { + bool first = true; + context& ctx = _context (); + + for (string_sequence::const_iterator i (value_->begin ()), + e (value_->end ()); i != e; ++i) + { +#ifdef XSDE_EXCEPTIONS + serializer_.pre (*i); + + if (!first) + _characters (" ", 1); + else + first = false; + + serializer_._pre_impl (ctx); + serializer_._serialize_content (); + serializer_._post_impl (); + serializer_.post (); +#else + serializer_.pre (*i); + + if (serializer_._error_type ()) + serializer_._copy_error (ctx); + + if (ctx.error_type ()) + break; + + if (!first) + { + if (!_characters (" ", 1)) + break; + } + else + first = false; + + serializer_._pre_impl (ctx); + + if (ctx.error_type ()) + break; + + serializer_._serialize_content (); + + if (ctx.error_type ()) + break; + + serializer_._post_impl (); + + if (ctx.error_type ()) + break; + + serializer_.post (); + + if (serializer_._error_type ()) + serializer_._copy_error (ctx); + + if (ctx.error_type ()) + break; +#endif + } + + if (free_) + { + delete const_cast<string_sequence*> (value_); + value_ = 0; + } + } + + void idrefs_simpl:: + _reset () + { + idrefs_sskel::_reset (); + serializer_._reset (); + } + } + } + } +} + diff --git a/libxsde/xsde/cxx/serializer/non-validating/idrefs.hxx b/libxsde/xsde/cxx/serializer/non-validating/idrefs.hxx new file mode 100644 index 0000000..2eb7a9e --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/idrefs.hxx @@ -0,0 +1,52 @@ +// file : xsde/cxx/serializer/non-validating/idrefs.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_NON_VALIDATING_IDREFS_HXX +#define XSDE_CXX_SERIALIZER_NON_VALIDATING_IDREFS_HXX + +#include <xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx> +#include <xsde/cxx/serializer/non-validating/idref.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct idrefs_simpl: virtual idrefs_sskel +#else + struct idrefs_simpl: idrefs_sskel +#endif + { + virtual + ~idrefs_simpl (); + + idrefs_simpl (bool free = false); + + virtual void + pre (const string_sequence*); + + virtual void + _serialize_content (); + + virtual void + _reset (); + + protected: + bool free_; + const string_sequence* value_; + idref_simpl serializer_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/non-validating/idrefs.ixx> + +#endif // XSDE_CXX_SERIALIZER_NON_VALIDATING_IDREFS_HXX diff --git a/libxsde/xsde/cxx/serializer/non-validating/idrefs.ixx b/libxsde/xsde/cxx/serializer/non-validating/idrefs.ixx new file mode 100644 index 0000000..773270e --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/idrefs.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/non-validating/idrefs.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + inline idrefs_simpl:: + idrefs_simpl (bool free) + : free_ (free), value_ (0), serializer_ (false) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/int.cxx b/libxsde/xsde/cxx/serializer/non-validating/int.cxx new file mode 100644 index 0000000..ab318bc --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/int.cxx @@ -0,0 +1,43 @@ +// file : xsde/cxx/serializer/non-validating/int.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/non-validating/int.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + void int_simpl:: + pre (int value) + { + value_ = value; + } + + void int_simpl:: + _serialize_content () + { + // We only need strlen("-2147483649") + 1 characters to hold all + // representations of int. + // + char str[12]; + +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 12, "%d", value_); +#else + int n = sprintf (str, "%d", value_); +#endif + if (n > 0 && n < 12) + _characters (str, static_cast<size_t> (n)); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/int.hxx b/libxsde/xsde/cxx/serializer/non-validating/int.hxx new file mode 100644 index 0000000..a4712ac --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/int.hxx @@ -0,0 +1,39 @@ +// file : xsde/cxx/serializer/non-validating/int.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_NON_VALIDATING_INT_HXX +#define XSDE_CXX_SERIALIZER_NON_VALIDATING_INT_HXX + +#include <xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct int_simpl: virtual int_sskel +#else + struct int_simpl: int_sskel +#endif + { + virtual void + pre (int); + + virtual void + _serialize_content (); + + protected: + int value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_NON_VALIDATING_INT_HXX diff --git a/libxsde/xsde/cxx/serializer/non-validating/integer.cxx b/libxsde/xsde/cxx/serializer/non-validating/integer.cxx new file mode 100644 index 0000000..a9928fd --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/integer.cxx @@ -0,0 +1,43 @@ +// file : xsde/cxx/serializer/non-validating/integer.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/non-validating/integer.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + void integer_simpl:: + pre (long value) + { + value_ = value; + } + + void integer_simpl:: + _serialize_content () + { + // We only need strlen("-9223372036854775808") + 1 characters to + // hold all representations of (possibly 64-bit) long. + // + char str[21]; + +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 21, "%ld", value_); +#else + int n = sprintf (str, "%ld", value_); +#endif + if (n > 0 && n < 21) + _characters (str, static_cast<size_t> (n)); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/integer.hxx b/libxsde/xsde/cxx/serializer/non-validating/integer.hxx new file mode 100644 index 0000000..da83119 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/integer.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/non-validating/integer.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_NON_VALIDATING_INTEGER_HXX +#define XSDE_CXX_SERIALIZER_NON_VALIDATING_INTEGER_HXX + +#include <xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + // Arbitrary-length integer. Mapped to long. + // +#ifdef XSDE_REUSE_STYLE_MIXIN + struct integer_simpl: virtual integer_sskel +#else + struct integer_simpl: integer_sskel +#endif + { + virtual void + pre (long); + + virtual void + _serialize_content (); + + protected: + long value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_NON_VALIDATING_INTEGER_HXX diff --git a/libxsde/xsde/cxx/serializer/non-validating/language-stl.cxx b/libxsde/xsde/cxx/serializer/non-validating/language-stl.cxx new file mode 100644 index 0000000..ba60bdc --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/language-stl.cxx @@ -0,0 +1,35 @@ +// file : xsde/cxx/serializer/non-validating/language-stl.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/serializer/non-validating/language-stl.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + void language_simpl:: + pre (const std::string& value) + { + value_ = value; + } + + void language_simpl:: + _serialize_content () + { + // Make sure we don't hold any references to the string. + // + std::string tmp; + tmp.swap (value_); + + _characters (tmp.c_str (), tmp.size ()); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/language-stl.hxx b/libxsde/xsde/cxx/serializer/non-validating/language-stl.hxx new file mode 100644 index 0000000..b141c16 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/language-stl.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/non-validating/language-stl.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_NON_VALIDATING_LANGUAGE_STL_HXX +#define XSDE_CXX_SERIALIZER_NON_VALIDATING_LANGUAGE_STL_HXX + +#include <string> + +#include <xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct language_simpl: virtual language_sskel +#else + struct language_simpl: language_sskel +#endif + { + virtual void + pre (const std::string&); + + virtual void + _serialize_content (); + + protected: + std::string value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_NON_VALIDATING_LANGUAGE_STL_HXX diff --git a/libxsde/xsde/cxx/serializer/non-validating/language.cxx b/libxsde/xsde/cxx/serializer/non-validating/language.cxx new file mode 100644 index 0000000..558edae --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/language.cxx @@ -0,0 +1,43 @@ +// file : xsde/cxx/serializer/non-validating/language.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/serializer/non-validating/language.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + language_simpl:: + ~language_simpl () + { + if (free_) + delete[] const_cast<char*> (value_); + } + + void language_simpl:: + pre (const char* value) + { + value_ = value; + } + + void language_simpl:: + _serialize_content () + { + _characters (value_); + + if (free_) + { + delete[] const_cast<char*> (value_); + value_ = 0; + } + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/language.hxx b/libxsde/xsde/cxx/serializer/non-validating/language.hxx new file mode 100644 index 0000000..56ed635 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/language.hxx @@ -0,0 +1,47 @@ +// file : xsde/cxx/serializer/non-validating/language.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_NON_VALIDATING_LANGUAGE_HXX +#define XSDE_CXX_SERIALIZER_NON_VALIDATING_LANGUAGE_HXX + +#include <xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct language_simpl: virtual language_sskel +#else + struct language_simpl: language_sskel +#endif + { + virtual + ~language_simpl (); + + language_simpl (bool free = false); + + virtual void + pre (const char*); + + virtual void + _serialize_content (); + + protected: + bool free_; + const char* value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/non-validating/language.ixx> + +#endif // XSDE_CXX_SERIALIZER_NON_VALIDATING_LANGUAGE_HXX diff --git a/libxsde/xsde/cxx/serializer/non-validating/language.ixx b/libxsde/xsde/cxx/serializer/non-validating/language.ixx new file mode 100644 index 0000000..3b51aad --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/language.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/non-validating/language.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + inline language_simpl:: + language_simpl (bool free) + : free_ (free) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/long-long.cxx b/libxsde/xsde/cxx/serializer/non-validating/long-long.cxx new file mode 100644 index 0000000..364a71d --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/long-long.cxx @@ -0,0 +1,43 @@ +// file : xsde/cxx/serializer/non-validating/long-long.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/non-validating/long-long.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + void long_simpl:: + pre (long long value) + { + value_ = value; + } + + void long_simpl:: + _serialize_content () + { + // We only need strlen("-9223372036854775808") + 1 characters to + // hold all representations of long long. + // + char str[21]; + +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 21, "%lld", value_); +#else + int n = sprintf (str, "%lld", value_); +#endif + if (n > 0 && n < 21) + _characters (str, static_cast<size_t> (n)); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/long-long.hxx b/libxsde/xsde/cxx/serializer/non-validating/long-long.hxx new file mode 100644 index 0000000..545bb80 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/long-long.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/non-validating/long-long.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_NON_VALIDATING_LONG_LONG_HXX +#define XSDE_CXX_SERIALIZER_NON_VALIDATING_LONG_LONG_HXX + +#include <xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + // 64-bit signed integer + // +#ifdef XSDE_REUSE_STYLE_MIXIN + struct long_simpl: virtual long_sskel +#else + struct long_simpl: long_sskel +#endif + { + virtual void + pre (long long); + + virtual void + _serialize_content (); + + protected: + long long value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_NON_VALIDATING_LONG_LONG_HXX diff --git a/libxsde/xsde/cxx/serializer/non-validating/long.cxx b/libxsde/xsde/cxx/serializer/non-validating/long.cxx new file mode 100644 index 0000000..7a9c121 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/long.cxx @@ -0,0 +1,43 @@ +// file : xsde/cxx/serializer/non-validating/long.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/non-validating/long.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + void long_simpl:: + pre (long value) + { + value_ = value; + } + + void long_simpl:: + _serialize_content () + { + // We only need strlen("-9223372036854775808") + 1 characters to + // hold all representations of (possibly 64-bit) long. + // + char str[21]; + +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 21, "%ld", value_); +#else + int n = sprintf (str, "%ld", value_); +#endif + if (n > 0 && n < 21) + _characters (str, static_cast<size_t> (n)); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/long.hxx b/libxsde/xsde/cxx/serializer/non-validating/long.hxx new file mode 100644 index 0000000..a4c63e7 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/long.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/non-validating/long.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_NON_VALIDATING_LONG_HXX +#define XSDE_CXX_SERIALIZER_NON_VALIDATING_LONG_HXX + +#include <xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + // Fall-back implementation when 64 bit long long is not available. + // +#ifdef XSDE_REUSE_STYLE_MIXIN + struct long_simpl: virtual long_sskel +#else + struct long_simpl: long_sskel +#endif + { + virtual void + pre (long); + + virtual void + _serialize_content (); + + protected: + long value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_NON_VALIDATING_LONG_HXX diff --git a/libxsde/xsde/cxx/serializer/non-validating/name-stl.cxx b/libxsde/xsde/cxx/serializer/non-validating/name-stl.cxx new file mode 100644 index 0000000..d84fd65 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/name-stl.cxx @@ -0,0 +1,35 @@ +// file : xsde/cxx/serializer/non-validating/name-stl.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/serializer/non-validating/name-stl.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + void name_simpl:: + pre (const std::string& value) + { + value_ = value; + } + + void name_simpl:: + _serialize_content () + { + // Make sure we don't hold any references to the string. + // + std::string tmp; + tmp.swap (value_); + + _characters (tmp.c_str (), tmp.size ()); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/name-stl.hxx b/libxsde/xsde/cxx/serializer/non-validating/name-stl.hxx new file mode 100644 index 0000000..f06b279 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/name-stl.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/non-validating/name-stl.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_NON_VALIDATING_NAME_STL_HXX +#define XSDE_CXX_SERIALIZER_NON_VALIDATING_NAME_STL_HXX + +#include <string> + +#include <xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct name_simpl: virtual name_sskel +#else + struct name_simpl: name_sskel +#endif + { + virtual void + pre (const std::string&); + + virtual void + _serialize_content (); + + protected: + std::string value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_NON_VALIDATING_NAME_STL_HXX diff --git a/libxsde/xsde/cxx/serializer/non-validating/name.cxx b/libxsde/xsde/cxx/serializer/non-validating/name.cxx new file mode 100644 index 0000000..70cb5c3 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/name.cxx @@ -0,0 +1,43 @@ +// file : xsde/cxx/serializer/non-validating/name.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/serializer/non-validating/name.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + name_simpl:: + ~name_simpl () + { + if (free_) + delete[] const_cast<char*> (value_); + } + + void name_simpl:: + pre (const char* value) + { + value_ = value; + } + + void name_simpl:: + _serialize_content () + { + _characters (value_); + + if (free_) + { + delete[] const_cast<char*> (value_); + value_ = 0; + } + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/name.hxx b/libxsde/xsde/cxx/serializer/non-validating/name.hxx new file mode 100644 index 0000000..8a36591 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/name.hxx @@ -0,0 +1,47 @@ +// file : xsde/cxx/serializer/non-validating/name.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_NON_VALIDATING_NAME_HXX +#define XSDE_CXX_SERIALIZER_NON_VALIDATING_NAME_HXX + +#include <xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct name_simpl: virtual name_sskel +#else + struct name_simpl: name_sskel +#endif + { + virtual + ~name_simpl (); + + name_simpl (bool free = false); + + virtual void + pre (const char*); + + virtual void + _serialize_content (); + + protected: + bool free_; + const char* value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/non-validating/name.ixx> + +#endif // XSDE_CXX_SERIALIZER_NON_VALIDATING_NAME_HXX diff --git a/libxsde/xsde/cxx/serializer/non-validating/name.ixx b/libxsde/xsde/cxx/serializer/non-validating/name.ixx new file mode 100644 index 0000000..f927928 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/name.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/non-validating/name.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + inline name_simpl:: + name_simpl (bool free) + : free_ (free) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/ncname-stl.cxx b/libxsde/xsde/cxx/serializer/non-validating/ncname-stl.cxx new file mode 100644 index 0000000..3e31290 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/ncname-stl.cxx @@ -0,0 +1,35 @@ +// file : xsde/cxx/serializer/non-validating/ncname-stl.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/serializer/non-validating/ncname-stl.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + void ncname_simpl:: + pre (const std::string& value) + { + value_ = value; + } + + void ncname_simpl:: + _serialize_content () + { + // Make sure we don't hold any references to the string. + // + std::string tmp; + tmp.swap (value_); + + _characters (tmp.c_str (), tmp.size ()); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/ncname-stl.hxx b/libxsde/xsde/cxx/serializer/non-validating/ncname-stl.hxx new file mode 100644 index 0000000..781b513 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/ncname-stl.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/non-validating/ncname-stl.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_NON_VALIDATING_NCNAME_STL_HXX +#define XSDE_CXX_SERIALIZER_NON_VALIDATING_NCNAME_STL_HXX + +#include <string> + +#include <xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct ncname_simpl: virtual ncname_sskel +#else + struct ncname_simpl: ncname_sskel +#endif + { + virtual void + pre (const std::string&); + + virtual void + _serialize_content (); + + protected: + std::string value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_NON_VALIDATING_NCNAME_STL_HXX diff --git a/libxsde/xsde/cxx/serializer/non-validating/ncname.cxx b/libxsde/xsde/cxx/serializer/non-validating/ncname.cxx new file mode 100644 index 0000000..ba39a06 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/ncname.cxx @@ -0,0 +1,43 @@ +// file : xsde/cxx/serializer/non-validating/ncname.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/serializer/non-validating/ncname.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + ncname_simpl:: + ~ncname_simpl () + { + if (free_) + delete[] const_cast<char*> (value_); + } + + void ncname_simpl:: + pre (const char* value) + { + value_ = value; + } + + void ncname_simpl:: + _serialize_content () + { + _characters (value_); + + if (free_) + { + delete[] const_cast<char*> (value_); + value_ = 0; + } + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/ncname.hxx b/libxsde/xsde/cxx/serializer/non-validating/ncname.hxx new file mode 100644 index 0000000..93a85c5 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/ncname.hxx @@ -0,0 +1,47 @@ +// file : xsde/cxx/serializer/non-validating/ncname.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_NON_VALIDATING_NCNAME_HXX +#define XSDE_CXX_SERIALIZER_NON_VALIDATING_NCNAME_HXX + +#include <xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct ncname_simpl: virtual ncname_sskel +#else + struct ncname_simpl: ncname_sskel +#endif + { + virtual + ~ncname_simpl (); + + ncname_simpl (bool free = false); + + virtual void + pre (const char*); + + virtual void + _serialize_content (); + + protected: + bool free_; + const char* value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/non-validating/ncname.ixx> + +#endif // XSDE_CXX_SERIALIZER_NON_VALIDATING_NCNAME_HXX diff --git a/libxsde/xsde/cxx/serializer/non-validating/ncname.ixx b/libxsde/xsde/cxx/serializer/non-validating/ncname.ixx new file mode 100644 index 0000000..36785d6 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/ncname.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/non-validating/ncname.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + inline ncname_simpl:: + ncname_simpl (bool free) + : free_ (free) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/negative-integer.cxx b/libxsde/xsde/cxx/serializer/non-validating/negative-integer.cxx new file mode 100644 index 0000000..713968d --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/negative-integer.cxx @@ -0,0 +1,43 @@ +// file : xsde/cxx/serializer/non-validating/negative-integer.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/non-validating/negative-integer.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + void negative_integer_simpl:: + pre (long value) + { + value_ = value; + } + + void negative_integer_simpl:: + _serialize_content () + { + // We only need strlen("-9223372036854775808") + 1 characters to + // hold all representations of (possibly 64-bit) long. + // + char str[21]; + +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 21, "%ld", value_); +#else + int n = sprintf (str, "%ld", value_); +#endif + if (n > 0 && n < 21) + _characters (str, static_cast<size_t> (n)); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/negative-integer.hxx b/libxsde/xsde/cxx/serializer/non-validating/negative-integer.hxx new file mode 100644 index 0000000..d8d7367 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/negative-integer.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/non-validating/negative-integer.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_NON_VALIDATING_NEGATIVE_INTEGER_HXX +#define XSDE_CXX_SERIALIZER_NON_VALIDATING_NEGATIVE_INTEGER_HXX + +#include <xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + // Arbitrary-length negative integer. Mapped to long. + // +#ifdef XSDE_REUSE_STYLE_MIXIN + struct negative_integer_simpl: virtual negative_integer_sskel +#else + struct negative_integer_simpl: negative_integer_sskel +#endif + { + virtual void + pre (long); + + virtual void + _serialize_content (); + + protected: + long value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_NON_VALIDATING_NEGATIVE_INTEGER_HXX diff --git a/libxsde/xsde/cxx/serializer/non-validating/nmtoken-stl.cxx b/libxsde/xsde/cxx/serializer/non-validating/nmtoken-stl.cxx new file mode 100644 index 0000000..a23aa22 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/nmtoken-stl.cxx @@ -0,0 +1,35 @@ +// file : xsde/cxx/serializer/non-validating/nmtoken-stl.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/serializer/non-validating/nmtoken-stl.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + void nmtoken_simpl:: + pre (const std::string& value) + { + value_ = value; + } + + void nmtoken_simpl:: + _serialize_content () + { + // Make sure we don't hold any references to the string. + // + std::string tmp; + tmp.swap (value_); + + _characters (tmp.c_str (), tmp.size ()); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/nmtoken-stl.hxx b/libxsde/xsde/cxx/serializer/non-validating/nmtoken-stl.hxx new file mode 100644 index 0000000..e5b56b4 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/nmtoken-stl.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/non-validating/nmtoken-stl.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_NON_VALIDATING_NMTOKEN_STL_HXX +#define XSDE_CXX_SERIALIZER_NON_VALIDATING_NMTOKEN_STL_HXX + +#include <string> + +#include <xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct nmtoken_simpl: virtual nmtoken_sskel +#else + struct nmtoken_simpl: nmtoken_sskel +#endif + { + virtual void + pre (const std::string&); + + virtual void + _serialize_content (); + + protected: + std::string value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_NON_VALIDATING_NMTOKEN_STL_HXX diff --git a/libxsde/xsde/cxx/serializer/non-validating/nmtoken.cxx b/libxsde/xsde/cxx/serializer/non-validating/nmtoken.cxx new file mode 100644 index 0000000..45132f1 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/nmtoken.cxx @@ -0,0 +1,43 @@ +// file : xsde/cxx/serializer/non-validating/nmtoken.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/serializer/non-validating/nmtoken.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + nmtoken_simpl:: + ~nmtoken_simpl () + { + if (free_) + delete[] const_cast<char*> (value_); + } + + void nmtoken_simpl:: + pre (const char* value) + { + value_ = value; + } + + void nmtoken_simpl:: + _serialize_content () + { + _characters (value_); + + if (free_) + { + delete[] const_cast<char*> (value_); + value_ = 0; + } + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/nmtoken.hxx b/libxsde/xsde/cxx/serializer/non-validating/nmtoken.hxx new file mode 100644 index 0000000..14642c9 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/nmtoken.hxx @@ -0,0 +1,47 @@ +// file : xsde/cxx/serializer/non-validating/nmtoken.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_NON_VALIDATING_NMTOKEN_HXX +#define XSDE_CXX_SERIALIZER_NON_VALIDATING_NMTOKEN_HXX + +#include <xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct nmtoken_simpl: virtual nmtoken_sskel +#else + struct nmtoken_simpl: nmtoken_sskel +#endif + { + virtual + ~nmtoken_simpl (); + + nmtoken_simpl (bool free = false); + + virtual void + pre (const char*); + + virtual void + _serialize_content (); + + protected: + bool free_; + const char* value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/non-validating/nmtoken.ixx> + +#endif // XSDE_CXX_SERIALIZER_NON_VALIDATING_NMTOKEN_HXX diff --git a/libxsde/xsde/cxx/serializer/non-validating/nmtoken.ixx b/libxsde/xsde/cxx/serializer/non-validating/nmtoken.ixx new file mode 100644 index 0000000..68ebd47 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/nmtoken.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/non-validating/nmtoken.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + inline nmtoken_simpl:: + nmtoken_simpl (bool free) + : free_ (free) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/nmtokens-stl.cxx b/libxsde/xsde/cxx/serializer/non-validating/nmtokens-stl.cxx new file mode 100644 index 0000000..afa663f --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/nmtokens-stl.cxx @@ -0,0 +1,108 @@ +// file : xsde/cxx/serializer/non-validating/nmtokens-stl.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/serializer/non-validating/nmtokens-stl.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + nmtokens_simpl:: + ~nmtokens_simpl () + { + if (free_) + delete const_cast<string_sequence*> (value_); + } + + void nmtokens_simpl:: + pre (const string_sequence* value) + { + value_ = value; + } + + void nmtokens_simpl:: + _serialize_content () + { + bool first = true; + context& ctx = _context (); + + for (string_sequence::const_iterator i (value_->begin ()), + e (value_->end ()); i != e; ++i) + { +#ifdef XSDE_EXCEPTIONS + serializer_.pre (*i); + + if (!first) + _characters (" ", 1); + else + first = false; + + serializer_._pre_impl (ctx); + serializer_._serialize_content (); + serializer_._post_impl (); + serializer_.post (); +#else + serializer_.pre (*i); + + if (serializer_._error_type ()) + serializer_._copy_error (ctx); + + if (ctx.error_type ()) + break; + + if (!first) + { + if (!_characters (" ", 1)) + break; + } + else + first = false; + + serializer_._pre_impl (ctx); + + if (ctx.error_type ()) + break; + + serializer_._serialize_content (); + + if (ctx.error_type ()) + break; + + serializer_._post_impl (); + + if (ctx.error_type ()) + break; + + serializer_.post (); + + if (serializer_._error_type ()) + serializer_._copy_error (ctx); + + if (ctx.error_type ()) + break; +#endif + } + + if (free_) + { + delete const_cast<string_sequence*> (value_); + value_ = 0; + } + } + + void nmtokens_simpl:: + _reset () + { + nmtokens_sskel::_reset (); + serializer_._reset (); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/nmtokens-stl.hxx b/libxsde/xsde/cxx/serializer/non-validating/nmtokens-stl.hxx new file mode 100644 index 0000000..da6ec57 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/nmtokens-stl.hxx @@ -0,0 +1,52 @@ +// file : xsde/cxx/serializer/non-validating/nmtokens-stl.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_NON_VALIDATING_NMTOKENS_STL_HXX +#define XSDE_CXX_SERIALIZER_NON_VALIDATING_NMTOKENS_STL_HXX + +#include <xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx> +#include <xsde/cxx/serializer/non-validating/nmtoken-stl.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct nmtokens_simpl: virtual nmtokens_sskel +#else + struct nmtokens_simpl: nmtokens_sskel +#endif + { + virtual + ~nmtokens_simpl (); + + nmtokens_simpl (bool free = false); + + virtual void + pre (const string_sequence*); + + virtual void + _serialize_content (); + + virtual void + _reset (); + + protected: + bool free_; + const string_sequence* value_; + nmtoken_simpl serializer_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/non-validating/nmtokens-stl.ixx> + +#endif // XSDE_CXX_SERIALIZER_NON_VALIDATING_NMTOKENS_STL_HXX diff --git a/libxsde/xsde/cxx/serializer/non-validating/nmtokens-stl.ixx b/libxsde/xsde/cxx/serializer/non-validating/nmtokens-stl.ixx new file mode 100644 index 0000000..b0236d8 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/nmtokens-stl.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/non-validating/nmtokens-stl.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + inline nmtokens_simpl:: + nmtokens_simpl (bool free) + : free_ (free), value_ (0) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/nmtokens.cxx b/libxsde/xsde/cxx/serializer/non-validating/nmtokens.cxx new file mode 100644 index 0000000..f430bda --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/nmtokens.cxx @@ -0,0 +1,109 @@ +// file : xsde/cxx/serializer/non-validating/nmtokens.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/serializer/non-validating/nmtokens.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + nmtokens_simpl:: + ~nmtokens_simpl () + { + if (free_) + delete const_cast<string_sequence*> (value_); + } + + void nmtokens_simpl:: + pre (const string_sequence* value) + { + value_ = value; + } + + void nmtokens_simpl:: + _serialize_content () + { + bool first = true; + context& ctx = _context (); + + for (string_sequence::const_iterator i (value_->begin ()), + e (value_->end ()); i != e; ++i) + { +#ifdef XSDE_EXCEPTIONS + serializer_.pre (*i); + + if (!first) + _characters (" ", 1); + else + first = false; + + serializer_._pre_impl (ctx); + serializer_._serialize_content (); + serializer_._post_impl (); + serializer_.post (); +#else + serializer_.pre (*i); + + if (serializer_._error_type ()) + serializer_._copy_error (ctx); + + if (ctx.error_type ()) + break; + + if (!first) + { + if (!_characters (" ", 1)) + break; + } + else + first = false; + + serializer_._pre_impl (ctx); + + if (ctx.error_type ()) + break; + + serializer_._serialize_content (); + + if (ctx.error_type ()) + break; + + serializer_._post_impl (); + + if (ctx.error_type ()) + break; + + serializer_.post (); + + if (serializer_._error_type ()) + serializer_._copy_error (ctx); + + if (ctx.error_type ()) + break; +#endif + } + + if (free_) + { + delete const_cast<string_sequence*> (value_); + value_ = 0; + } + } + + void nmtokens_simpl:: + _reset () + { + nmtokens_sskel::_reset (); + serializer_._reset (); + } + } + } + } +} + diff --git a/libxsde/xsde/cxx/serializer/non-validating/nmtokens.hxx b/libxsde/xsde/cxx/serializer/non-validating/nmtokens.hxx new file mode 100644 index 0000000..8a0f651 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/nmtokens.hxx @@ -0,0 +1,52 @@ +// file : xsde/cxx/serializer/non-validating/nmtokens.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_NON_VALIDATING_NMTOKENS_HXX +#define XSDE_CXX_SERIALIZER_NON_VALIDATING_NMTOKENS_HXX + +#include <xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx> +#include <xsde/cxx/serializer/non-validating/nmtoken.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct nmtokens_simpl: virtual nmtokens_sskel +#else + struct nmtokens_simpl: nmtokens_sskel +#endif + { + virtual + ~nmtokens_simpl (); + + nmtokens_simpl (bool free = false); + + virtual void + pre (const string_sequence*); + + virtual void + _serialize_content (); + + virtual void + _reset (); + + protected: + bool free_; + const string_sequence* value_; + nmtoken_simpl serializer_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/non-validating/nmtokens.ixx> + +#endif // XSDE_CXX_SERIALIZER_NON_VALIDATING_NMTOKENS_HXX diff --git a/libxsde/xsde/cxx/serializer/non-validating/nmtokens.ixx b/libxsde/xsde/cxx/serializer/non-validating/nmtokens.ixx new file mode 100644 index 0000000..43af4b2 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/nmtokens.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/non-validating/nmtokens.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + inline nmtokens_simpl:: + nmtokens_simpl (bool free) + : free_ (free), value_ (0), serializer_ (false) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/non-negative-integer.cxx b/libxsde/xsde/cxx/serializer/non-validating/non-negative-integer.cxx new file mode 100644 index 0000000..8a3ee77 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/non-negative-integer.cxx @@ -0,0 +1,43 @@ +// file : xsde/cxx/serializer/non-validating/non-negative-integer.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/non-validating/non-negative-integer.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + void non_negative_integer_simpl:: + pre (unsigned long value) + { + value_ = value; + } + + void non_negative_integer_simpl:: + _serialize_content () + { + // We only need strlen("18446744073709551615") + 1 characters to + // hold all representations of (possibly 64-bit) unsigned long. + // + char str[21]; + +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 21, "%lu", value_); +#else + int n = sprintf (str, "%lu", value_); +#endif + if (n > 0 && n < 21) + _characters (str, static_cast<size_t> (n)); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/non-negative-integer.hxx b/libxsde/xsde/cxx/serializer/non-validating/non-negative-integer.hxx new file mode 100644 index 0000000..ba9e1f3 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/non-negative-integer.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/non-validating/non-negative-integer.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_NON_VALIDATING_NON_NEGATIVE_INTEGER_HXX +#define XSDE_CXX_SERIALIZER_NON_VALIDATING_NON_NEGATIVE_INTEGER_HXX + +#include <xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + // Arbitrary-length non-negative integer. Mapped to unsigned long. + // +#ifdef XSDE_REUSE_STYLE_MIXIN + struct non_negative_integer_simpl: virtual non_negative_integer_sskel +#else + struct non_negative_integer_simpl: non_negative_integer_sskel +#endif + { + virtual void + pre (unsigned long); + + virtual void + _serialize_content (); + + protected: + unsigned long value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_NON_VALIDATING_NON_NEGATIVE_INTEGER_HXX diff --git a/libxsde/xsde/cxx/serializer/non-validating/non-positive-integer.cxx b/libxsde/xsde/cxx/serializer/non-validating/non-positive-integer.cxx new file mode 100644 index 0000000..4aa51d0 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/non-positive-integer.cxx @@ -0,0 +1,43 @@ +// file : xsde/cxx/serializer/non-validating/non-positive-integer.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/non-validating/non-positive-integer.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + void non_positive_integer_simpl:: + pre (long value) + { + value_ = value; + } + + void non_positive_integer_simpl:: + _serialize_content () + { + // We only need strlen("-9223372036854775808") + 1 characters to + // hold all representations of (possibly 64-bit) long. + // + char str[21]; + +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 21, "%ld", value_); +#else + int n = sprintf (str, "%ld", value_); +#endif + if (n > 0 && n < 21) + _characters (str, static_cast<size_t> (n)); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/non-positive-integer.hxx b/libxsde/xsde/cxx/serializer/non-validating/non-positive-integer.hxx new file mode 100644 index 0000000..5e8c212 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/non-positive-integer.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/non-validating/non-positive-integer.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_NON_VALIDATING_NON_POSITIVE_INTEGER_HXX +#define XSDE_CXX_SERIALIZER_NON_VALIDATING_NON_POSITIVE_INTEGER_HXX + +#include <xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + // Arbitrary-length non-positive integer. Mapped to long. + // +#ifdef XSDE_REUSE_STYLE_MIXIN + struct non_positive_integer_simpl: virtual non_positive_integer_sskel +#else + struct non_positive_integer_simpl: non_positive_integer_sskel +#endif + { + virtual void + pre (long); + + virtual void + _serialize_content (); + + protected: + long value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_NON_VALIDATING_NON_POSITIVE_INTEGER_HXX diff --git a/libxsde/xsde/cxx/serializer/non-validating/normalized-string-stl.cxx b/libxsde/xsde/cxx/serializer/non-validating/normalized-string-stl.cxx new file mode 100644 index 0000000..c96c9cf --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/normalized-string-stl.cxx @@ -0,0 +1,36 @@ +// file : xsde/cxx/serializer/non-validating/normalized-string-stl.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/serializer/non-validating/normalized-string-stl.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + void normalized_string_simpl:: + pre (const std::string& value) + { + value_ = value; + } + + void normalized_string_simpl:: + _serialize_content () + { + // Make sure we don't hold any references to the string. + // + std::string tmp; + tmp.swap (value_); + + _characters (tmp.c_str (), tmp.size ()); + } + } + } + } +} + diff --git a/libxsde/xsde/cxx/serializer/non-validating/normalized-string-stl.hxx b/libxsde/xsde/cxx/serializer/non-validating/normalized-string-stl.hxx new file mode 100644 index 0000000..65da3b6 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/normalized-string-stl.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/non-validating/normalized-string-stl.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_NON_VALIDATING_NORMALIZED_STRING_STL_HXX +#define XSDE_CXX_SERIALIZER_NON_VALIDATING_NORMALIZED_STRING_STL_HXX + +#include <string> + +#include <xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct normalized_string_simpl: virtual normalized_string_sskel +#else + struct normalized_string_simpl: normalized_string_sskel +#endif + { + virtual void + pre (const std::string&); + + virtual void + _serialize_content (); + + protected: + std::string value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_NON_VALIDATING_NORMALIZED_STRING_STL_HXX diff --git a/libxsde/xsde/cxx/serializer/non-validating/normalized-string.cxx b/libxsde/xsde/cxx/serializer/non-validating/normalized-string.cxx new file mode 100644 index 0000000..fd69cec --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/normalized-string.cxx @@ -0,0 +1,44 @@ +// file : xsde/cxx/serializer/non-validating/normalized-string.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/serializer/non-validating/normalized-string.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + normalized_string_simpl:: + ~normalized_string_simpl () + { + if (free_) + delete[] const_cast<char*> (value_); + } + + void normalized_string_simpl:: + pre (const char* value) + { + value_ = value; + } + + void normalized_string_simpl:: + _serialize_content () + { + _characters (value_); + + if (free_) + { + delete[] const_cast<char*> (value_); + value_ = 0; + } + } + } + } + } +} + diff --git a/libxsde/xsde/cxx/serializer/non-validating/normalized-string.hxx b/libxsde/xsde/cxx/serializer/non-validating/normalized-string.hxx new file mode 100644 index 0000000..1ae4270 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/normalized-string.hxx @@ -0,0 +1,47 @@ +// file : xsde/cxx/serializer/non-validating/normalized-string.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_NON_VALIDATING_NORMALIZED_STRING_HXX +#define XSDE_CXX_SERIALIZER_NON_VALIDATING_NORMALIZED_STRING_HXX + +#include <xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct normalized_string_simpl: virtual normalized_string_sskel +#else + struct normalized_string_simpl: normalized_string_sskel +#endif + { + virtual + ~normalized_string_simpl (); + + normalized_string_simpl (bool free = false); + + virtual void + pre (const char*); + + virtual void + _serialize_content (); + + protected: + bool free_; + const char* value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/non-validating/normalized-string.ixx> + +#endif // XSDE_CXX_SERIALIZER_NON_VALIDATING_NORMALIZED_STRING_HXX diff --git a/libxsde/xsde/cxx/serializer/non-validating/normalized-string.ixx b/libxsde/xsde/cxx/serializer/non-validating/normalized-string.ixx new file mode 100644 index 0000000..627b93a --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/normalized-string.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/non-validating/normalized-string.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + inline normalized_string_simpl:: + normalized_string_simpl (bool free) + : free_ (free) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/positive-integer.cxx b/libxsde/xsde/cxx/serializer/non-validating/positive-integer.cxx new file mode 100644 index 0000000..193499e --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/positive-integer.cxx @@ -0,0 +1,43 @@ +// file : xsde/cxx/serializer/non-validating/positive-integer.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/non-validating/positive-integer.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + void positive_integer_simpl:: + pre (unsigned long value) + { + value_ = value; + } + + void positive_integer_simpl:: + _serialize_content () + { + // We only need strlen("18446744073709551615") + 1 characters to + // hold all representations of (possibly 64-bit) unsigned long. + // + char str[21]; + +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 21, "%lu", value_); +#else + int n = sprintf (str, "%lu", value_); +#endif + if (n > 0 && n < 21) + _characters (str, static_cast<size_t> (n)); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/positive-integer.hxx b/libxsde/xsde/cxx/serializer/non-validating/positive-integer.hxx new file mode 100644 index 0000000..397e904 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/positive-integer.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/non-validating/positive-integer.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_NON_VALIDATING_POSITIVE_INTEGER_HXX +#define XSDE_CXX_SERIALIZER_NON_VALIDATING_POSITIVE_INTEGER_HXX + +#include <xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + // Arbitrary-length positive integer. Mapped to unsigned long. + // +#ifdef XSDE_REUSE_STYLE_MIXIN + struct positive_integer_simpl: virtual positive_integer_sskel +#else + struct positive_integer_simpl: positive_integer_sskel +#endif + { + virtual void + pre (unsigned long); + + virtual void + _serialize_content (); + + protected: + unsigned long value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_NON_VALIDATING_POSITIVE_INTEGER_HXX diff --git a/libxsde/xsde/cxx/serializer/non-validating/qname-stl.cxx b/libxsde/xsde/cxx/serializer/non-validating/qname-stl.cxx new file mode 100644 index 0000000..92c0b57 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/qname-stl.cxx @@ -0,0 +1,50 @@ +// file : xsde/cxx/serializer/non-validating/qname-stl.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/serializer/non-validating/qname-stl.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + void qname_simpl:: + pre (const qname& value) + { + value_ = value; + } + + void qname_simpl:: + _serialize_content () + { + // Make sure we don't hold any references to the qname. + // + qname tmp ("a"); + tmp.swap (value_); + + if (!tmp.prefix ().empty ()) + { +#ifdef XSDE_EXCEPTIONS + _characters (tmp.prefix ().c_str (), tmp.prefix ().size ()); + _characters (":", 1); + _characters (tmp.name ().c_str (), tmp.name ().size ()); +#else + if (_characters (tmp.prefix ().c_str (), tmp.prefix ().size ())) + { + if (_characters (":", 1)) + _characters (tmp.name ().c_str (), tmp.name ().size ()); + } +#endif + } + else + _characters (tmp.name ().c_str (), tmp.name ().size ()); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/qname-stl.hxx b/libxsde/xsde/cxx/serializer/non-validating/qname-stl.hxx new file mode 100644 index 0000000..9163de5 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/qname-stl.hxx @@ -0,0 +1,43 @@ +// file : xsde/cxx/serializer/non-validating/qname-stl.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_NON_VALIDATING_QNAME_STL_HXX +#define XSDE_CXX_SERIALIZER_NON_VALIDATING_QNAME_STL_HXX + +#include <xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct qname_simpl: virtual qname_sskel +#else + struct qname_simpl: qname_sskel +#endif + { + qname_simpl (); + + virtual void + pre (const qname&); + + virtual void + _serialize_content (); + + protected: + qname value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/non-validating/qname-stl.ixx> + +#endif // XSDE_CXX_SERIALIZER_NON_VALIDATING_QNAME_STL_HXX diff --git a/libxsde/xsde/cxx/serializer/non-validating/qname-stl.ixx b/libxsde/xsde/cxx/serializer/non-validating/qname-stl.ixx new file mode 100644 index 0000000..d4bff2d --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/qname-stl.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/non-validating/qname-stl.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + inline qname_simpl:: + qname_simpl () + : value_ ("a") + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/qname.cxx b/libxsde/xsde/cxx/serializer/non-validating/qname.cxx new file mode 100644 index 0000000..d2e41ff --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/qname.cxx @@ -0,0 +1,62 @@ +// file : xsde/cxx/serializer/non-validating/qname.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/serializer/non-validating/qname.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + qname_simpl:: + ~qname_simpl () + { + if (free_) + delete const_cast<qname*> (value_); + } + + void qname_simpl:: + pre (const qname* value) + { + value_ = value; + } + + void qname_simpl:: + _serialize_content () + { + const char* p = value_->prefix (); + + if (p != 0 && *p != '\0') + { +#ifdef XSDE_EXCEPTIONS + _characters (p); + _characters (":", 1); + _characters (value_->name ()); +#else + if (_characters (p)) + { + if (_characters (":", 1)) + _characters (value_->name ()); + } +#endif + } + else + { + _characters (value_->name ()); + } + + if (free_) + { + delete const_cast<qname*> (value_); + value_ = 0; + } + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/qname.hxx b/libxsde/xsde/cxx/serializer/non-validating/qname.hxx new file mode 100644 index 0000000..4916726 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/qname.hxx @@ -0,0 +1,47 @@ +// file : xsde/cxx/serializer/non-validating/qname.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_NON_VALIDATING_QNAME_HXX +#define XSDE_CXX_SERIALIZER_NON_VALIDATING_QNAME_HXX + +#include <xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct qname_simpl: virtual qname_sskel +#else + struct qname_simpl: qname_sskel +#endif + { + virtual + ~qname_simpl (); + + qname_simpl (bool free = false); + + virtual void + pre (const qname*); + + virtual void + _serialize_content (); + + protected: + bool free_; + const qname* value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/non-validating/qname.ixx> + +#endif // XSDE_CXX_SERIALIZER_NON_VALIDATING_QNAME_HXX diff --git a/libxsde/xsde/cxx/serializer/non-validating/qname.ixx b/libxsde/xsde/cxx/serializer/non-validating/qname.ixx new file mode 100644 index 0000000..e89b8b9 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/qname.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/non-validating/qname.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + inline qname_simpl:: + qname_simpl (bool free) + : free_ (free), value_ (0) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/serializer.cxx b/libxsde/xsde/cxx/serializer/non-validating/serializer.cxx new file mode 100644 index 0000000..7da8599 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/serializer.cxx @@ -0,0 +1,29 @@ +// file : xsde/cxx/serializer/non-validating/serializer.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/serializer/non-validating/serializer.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + // simple_content + // +#ifdef XSDE_REUSE_STYLE_TIEIN + void simple_content:: + _serialize_content () + { + if (impl_) + impl_->_serialize_content (); + } +#endif + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/serializer.hxx b/libxsde/xsde/cxx/serializer/non-validating/serializer.hxx new file mode 100644 index 0000000..c01476b --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/serializer.hxx @@ -0,0 +1,58 @@ +// file : xsde/cxx/serializer/non-validating/serializer.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_NON_VALIDATING_SERIALIZER_HXX +#define XSDE_CXX_SERIALIZER_NON_VALIDATING_SERIALIZER_HXX + +#include <xsde/cxx/config.hxx> + +#include <xsde/cxx/serializer/elements.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + struct empty_content: serializer_base + { +#ifdef XSDE_REUSE_STYLE_TIEIN + empty_content (); + empty_content (empty_content* impl, void*); +#endif + }; + + // + // + struct simple_content: empty_content + { +#ifdef XSDE_REUSE_STYLE_TIEIN + virtual void + _serialize_content (); + + simple_content (); + simple_content (simple_content* impl, void*); +#endif + }; + + // + // + struct complex_content: empty_content + { +#ifdef XSDE_REUSE_STYLE_TIEIN + complex_content (); + complex_content (complex_content* impl, void*); +#endif + }; + } + } + } +} + +#include <xsde/cxx/serializer/non-validating/serializer.ixx> + +#endif // XSDE_CXX_SERIALIZER_NON_VALIDATING_SERIALIZER_HXX diff --git a/libxsde/xsde/cxx/serializer/non-validating/serializer.ixx b/libxsde/xsde/cxx/serializer/non-validating/serializer.ixx new file mode 100644 index 0000000..b8eacee --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/serializer.ixx @@ -0,0 +1,61 @@ +// file : xsde/cxx/serializer/non-validating/serializer.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + // empty_content + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline empty_content:: + empty_content () + { + } + + inline empty_content:: + empty_content (empty_content* impl, void*) + : serializer_base (impl, 0) + { + } +#endif + + // simple_content + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline simple_content:: + simple_content () + { + } + + inline simple_content:: + simple_content (simple_content* impl, void*) + : empty_content (impl, 0) + { + } +#endif + + // complex_content + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline complex_content:: + complex_content () + { + } + + inline complex_content:: + complex_content (complex_content* impl, void*) + : empty_content (impl, 0) + { + } +#endif + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/short.cxx b/libxsde/xsde/cxx/serializer/non-validating/short.cxx new file mode 100644 index 0000000..ad14306 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/short.cxx @@ -0,0 +1,43 @@ +// file : xsde/cxx/serializer/non-validating/short.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/non-validating/short.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + void short_simpl:: + pre (short value) + { + value_ = value; + } + + void short_simpl:: + _serialize_content () + { + // We only need strlen("-32768") + 1 characters to hold all + // representations of short. + // + char str[7]; + +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 7, "%d", value_); +#else + int n = sprintf (str, "%d", value_); +#endif + if (n > 0 && n < 7) + _characters (str, static_cast<size_t> (n)); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/short.hxx b/libxsde/xsde/cxx/serializer/non-validating/short.hxx new file mode 100644 index 0000000..fb763e7 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/short.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/non-validating/short.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_NON_VALIDATING_SHORT_HXX +#define XSDE_CXX_SERIALIZER_NON_VALIDATING_SHORT_HXX + +#include <xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + // 16-bit signed integer + // +#ifdef XSDE_REUSE_STYLE_MIXIN + struct short_simpl: virtual short_sskel +#else + struct short_simpl: short_sskel +#endif + { + virtual void + pre (short); + + virtual void + _serialize_content (); + + protected: + short value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_NON_VALIDATING_SHORT_HXX diff --git a/libxsde/xsde/cxx/serializer/non-validating/string-stl.cxx b/libxsde/xsde/cxx/serializer/non-validating/string-stl.cxx new file mode 100644 index 0000000..28ba3e9 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/string-stl.cxx @@ -0,0 +1,35 @@ +// file : xsde/cxx/serializer/non-validating/string-stl.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/serializer/non-validating/string-stl.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + void string_simpl:: + pre (const std::string& value) + { + value_ = value; + } + + void string_simpl:: + _serialize_content () + { + // Make sure we don't hold any references to the string. + // + std::string tmp; + tmp.swap (value_); + + _characters (tmp.c_str (), tmp.size ()); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/string-stl.hxx b/libxsde/xsde/cxx/serializer/non-validating/string-stl.hxx new file mode 100644 index 0000000..0aee653 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/string-stl.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/non-validating/string-stl.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_NON_VALIDATING_STRING_STL_HXX +#define XSDE_CXX_SERIALIZER_NON_VALIDATING_STRING_STL_HXX + +#include <string> + +#include <xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct string_simpl: virtual string_sskel +#else + struct string_simpl: string_sskel +#endif + { + virtual void + pre (const std::string&); + + virtual void + _serialize_content (); + + protected: + std::string value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_NON_VALIDATING_STRING_STL_HXX diff --git a/libxsde/xsde/cxx/serializer/non-validating/string.cxx b/libxsde/xsde/cxx/serializer/non-validating/string.cxx new file mode 100644 index 0000000..a56b3fa --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/string.cxx @@ -0,0 +1,43 @@ +// file : xsde/cxx/serializer/non-validating/string.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/serializer/non-validating/string.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + string_simpl:: + ~string_simpl () + { + if (free_) + delete[] const_cast<char*> (value_); + } + + void string_simpl:: + pre (const char* value) + { + value_ = value; + } + + void string_simpl:: + _serialize_content () + { + _characters (value_); + + if (free_) + { + delete[] const_cast<char*> (value_); + value_ = 0; + } + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/string.hxx b/libxsde/xsde/cxx/serializer/non-validating/string.hxx new file mode 100644 index 0000000..913e2de --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/string.hxx @@ -0,0 +1,47 @@ +// file : xsde/cxx/serializer/non-validating/string.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_NON_VALIDATING_STRING_HXX +#define XSDE_CXX_SERIALIZER_NON_VALIDATING_STRING_HXX + +#include <xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct string_simpl: virtual string_sskel +#else + struct string_simpl: string_sskel +#endif + { + virtual + ~string_simpl (); + + string_simpl (bool free = false); + + virtual void + pre (const char*); + + virtual void + _serialize_content (); + + protected: + bool free_; + const char* value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/non-validating/string.ixx> + +#endif // XSDE_CXX_SERIALIZER_NON_VALIDATING_STRING_HXX diff --git a/libxsde/xsde/cxx/serializer/non-validating/string.ixx b/libxsde/xsde/cxx/serializer/non-validating/string.ixx new file mode 100644 index 0000000..b620835 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/string.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/non-validating/string.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + inline string_simpl:: + string_simpl (bool free) + : free_ (free), value_ (0) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/time-zone.cxx b/libxsde/xsde/cxx/serializer/non-validating/time-zone.cxx new file mode 100644 index 0000000..8f374cf --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/time-zone.cxx @@ -0,0 +1,65 @@ +// file : xsde/cxx/serializer/non-validating/time-zone.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/config.hxx> + +#include <xsde/cxx/serializer/non-validating/time-zone.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + namespace bits + { + int + serialize_time_zone (char* s, const time_zone& z) + { + // time-zone := Z|(+|-)HH:MM + // + + short h = z.zone_hours (); + short m = z.zone_minutes (); + + if (h == 0 && m == 0) + { + *s = 'Z'; + return 1; + } + else + { + const char* fmt = "+%.2u:%.2u"; + + if (h < 0 || m < 0) + { + fmt = "-%.2u:%.2u"; + h = -h; + m = -m; + } + + if (h >= 0 && h <= 14 && m >= 0 && m <= 59) + { +#ifdef XSDE_SNPRINTF + int n = snprintf (s, 7, fmt, h, m); +#else + int n = sprintf (s, fmt, h, m); +#endif + if (n > 0 && n < 7) + return n; + } + + return 0; + } + } + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/time-zone.hxx b/libxsde/xsde/cxx/serializer/non-validating/time-zone.hxx new file mode 100644 index 0000000..3a342b4 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/time-zone.hxx @@ -0,0 +1,33 @@ +// file : xsde/cxx/serializer/non-validating/time-zone.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_NON_VALIDATING_TIME_ZONE_HXX +#define XSDE_CXX_SERIALIZER_NON_VALIDATING_TIME_ZONE_HXX + +#include <xsde/cxx/date-time.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + namespace bits + { + // Returns 0 in case of a failure and the number of + // characters written otherwise. The buffer should + // have space for at least 7 characters. + // + int + serialize_time_zone (char* s, const time_zone&); + } + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_NON_VALIDATING_TIME_ZONE_HXX diff --git a/libxsde/xsde/cxx/serializer/non-validating/time.cxx b/libxsde/xsde/cxx/serializer/non-validating/time.cxx new file mode 100644 index 0000000..7643d12 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/time.cxx @@ -0,0 +1,73 @@ +// file : xsde/cxx/serializer/non-validating/time.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/non-validating/time.hxx> +#include <xsde/cxx/serializer/non-validating/time-zone.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + void time_simpl:: + pre (const time& value) + { + value_ = value; + } + + void time_simpl:: + _serialize_content () + { + // We only need strlen("hh:mm:ss.ssssss-hh:mm") + 1 characters to + // hold all representations of time. We know that the seconds + // part (represented as double) has default precision of 6. + // + char str[22]; + + if (value_.hours () <= 24 && + value_.minutes () <= 59 && + value_.seconds () >= 0.0 && + value_.seconds () < 60.0) + { +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 16, "%.2u:%.2u:%09f", + value_.hours (), value_.minutes (), + value_.seconds ()); +#else + int n = sprintf (str, "%.2u:%.2u:%09f", + value_.hours (), value_.minutes (), + value_.seconds ()); +#endif + if (n > 0 && n < 16) + { + // Remove trailing '0' and '.' if necessary. + // + while (str[n - 1] == '0') + n--; + + if (str[n - 1] == '.') + n--; + + if (value_.zone_present ()) + { + if (int z = bits::serialize_time_zone (str + n, value_)) + n += z; + else + return; + } + + _characters (str, static_cast<size_t> (n)); + } + } + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/time.hxx b/libxsde/xsde/cxx/serializer/non-validating/time.hxx new file mode 100644 index 0000000..69680c5 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/time.hxx @@ -0,0 +1,43 @@ +// file : xsde/cxx/serializer/non-validating/time.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_NON_VALIDATING_TIME_HXX +#define XSDE_CXX_SERIALIZER_NON_VALIDATING_TIME_HXX + +#include <xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct time_simpl: virtual time_sskel +#else + struct time_simpl: time_sskel +#endif + { + time_simpl (); + + virtual void + pre (const time&); + + virtual void + _serialize_content (); + + protected: + time value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/non-validating/time.ixx> + +#endif // XSDE_CXX_SERIALIZER_NON_VALIDATING_TIME_HXX diff --git a/libxsde/xsde/cxx/serializer/non-validating/time.ixx b/libxsde/xsde/cxx/serializer/non-validating/time.ixx new file mode 100644 index 0000000..9a99cb6 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/time.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/non-validating/time.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + inline time_simpl:: + time_simpl () + : value_ (0, 0, 0.0) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/token-stl.cxx b/libxsde/xsde/cxx/serializer/non-validating/token-stl.cxx new file mode 100644 index 0000000..baf257a --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/token-stl.cxx @@ -0,0 +1,35 @@ +// file : xsde/cxx/serializer/non-validating/token-stl.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/serializer/non-validating/token-stl.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + void token_simpl:: + pre (const std::string& value) + { + value_ = value; + } + + void token_simpl:: + _serialize_content () + { + // Make sure we don't hold any references to the string. + // + std::string tmp; + tmp.swap (value_); + + _characters (tmp.c_str (), tmp.size ()); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/token-stl.hxx b/libxsde/xsde/cxx/serializer/non-validating/token-stl.hxx new file mode 100644 index 0000000..458cb6d --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/token-stl.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/non-validating/token-stl.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_NON_VALIDATING_TOKEN_STL_HXX +#define XSDE_CXX_SERIALIZER_NON_VALIDATING_TOKEN_STL_HXX + +#include <string> + +#include <xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct token_simpl: virtual token_sskel +#else + struct token_simpl: token_sskel +#endif + { + virtual void + pre (const std::string&); + + virtual void + _serialize_content (); + + protected: + std::string value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_NON_VALIDATING_TOKEN_STL_HXX diff --git a/libxsde/xsde/cxx/serializer/non-validating/token.cxx b/libxsde/xsde/cxx/serializer/non-validating/token.cxx new file mode 100644 index 0000000..e2bfd0e --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/token.cxx @@ -0,0 +1,43 @@ +// file : xsde/cxx/serializer/non-validating/token.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/serializer/non-validating/token.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + token_simpl:: + ~token_simpl () + { + if (free_) + delete[] const_cast<char*> (value_); + } + + void token_simpl:: + pre (const char* value) + { + value_ = value; + } + + void token_simpl:: + _serialize_content () + { + _characters (value_); + + if (free_) + { + delete[] const_cast<char*> (value_); + value_ = 0; + } + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/token.hxx b/libxsde/xsde/cxx/serializer/non-validating/token.hxx new file mode 100644 index 0000000..0133fd5 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/token.hxx @@ -0,0 +1,47 @@ +// file : xsde/cxx/serializer/non-validating/token.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_NON_VALIDATING_TOKEN_HXX +#define XSDE_CXX_SERIALIZER_NON_VALIDATING_TOKEN_HXX + +#include <xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct token_simpl: virtual token_sskel +#else + struct token_simpl: token_sskel +#endif + { + virtual + ~token_simpl (); + + token_simpl (bool free = false); + + virtual void + pre (const char*); + + virtual void + _serialize_content (); + + protected: + bool free_; + const char* value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/non-validating/token.ixx> + +#endif // XSDE_CXX_SERIALIZER_NON_VALIDATING_TOKEN_HXX diff --git a/libxsde/xsde/cxx/serializer/non-validating/token.ixx b/libxsde/xsde/cxx/serializer/non-validating/token.ixx new file mode 100644 index 0000000..9cb8594 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/token.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/non-validating/token.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + inline token_simpl:: + token_simpl (bool free) + : free_ (free) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/unsigned-byte.cxx b/libxsde/xsde/cxx/serializer/non-validating/unsigned-byte.cxx new file mode 100644 index 0000000..3d39100 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/unsigned-byte.cxx @@ -0,0 +1,43 @@ +// file : xsde/cxx/serializer/non-validating/unsigned-byte.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/non-validating/unsigned-byte.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + void unsigned_byte_simpl:: + pre (unsigned char value) + { + value_ = value; + } + + void unsigned_byte_simpl:: + _serialize_content () + { + // We only need strlen("256") + 1 characters to hold all + // representations of unsigned byte. + // + char str[4]; + +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 4, "%u", value_); +#else + int n = sprintf (str, "%u", value_); +#endif + if (n > 0 && n < 4) + _characters (str, static_cast<size_t> (n)); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/unsigned-byte.hxx b/libxsde/xsde/cxx/serializer/non-validating/unsigned-byte.hxx new file mode 100644 index 0000000..9c4f45e --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/unsigned-byte.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/non-validating/unsigned-byte.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_NON_VALIDATING_UNSIGNED_BYTE_HXX +#define XSDE_CXX_SERIALIZER_NON_VALIDATING_UNSIGNED_BYTE_HXX + +#include <xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + // 8-bit unsigned integer + // +#ifdef XSDE_REUSE_STYLE_MIXIN + struct unsigned_byte_simpl: virtual unsigned_byte_sskel +#else + struct unsigned_byte_simpl: unsigned_byte_sskel +#endif + { + virtual void + pre (unsigned char); + + virtual void + _serialize_content (); + + protected: + unsigned char value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_NON_VALIDATING_UNSIGNED_BYTE_HXX diff --git a/libxsde/xsde/cxx/serializer/non-validating/unsigned-int.cxx b/libxsde/xsde/cxx/serializer/non-validating/unsigned-int.cxx new file mode 100644 index 0000000..5f9f73a --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/unsigned-int.cxx @@ -0,0 +1,43 @@ +// file : xsde/cxx/serializer/non-validating/unsigned-int.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/non-validating/unsigned-int.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + void unsigned_int_simpl:: + pre (unsigned int value) + { + value_ = value; + } + + void unsigned_int_simpl:: + _serialize_content () + { + // We only need strlen("4294967295") + 1 characters to hold all + // representations of unsigned int. + // + char str[11]; + +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 11, "%u", value_); +#else + int n = sprintf (str, "%u", value_); +#endif + if (n > 0 && n < 11) + _characters (str, static_cast<size_t> (n)); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/unsigned-int.hxx b/libxsde/xsde/cxx/serializer/non-validating/unsigned-int.hxx new file mode 100644 index 0000000..66e88d0 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/unsigned-int.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/non-validating/unsigned-int.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_NON_VALIDATING_UNSIGNED_INT_HXX +#define XSDE_CXX_SERIALIZER_NON_VALIDATING_UNSIGNED_INT_HXX + +#include <xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + // 32-bit unsigned integer + // +#ifdef XSDE_REUSE_STYLE_MIXIN + struct unsigned_int_simpl: virtual unsigned_int_sskel +#else + struct unsigned_int_simpl: unsigned_int_sskel +#endif + { + virtual void + pre (unsigned int); + + virtual void + _serialize_content (); + + protected: + unsigned int value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_NON_VALIDATING_UNSIGNED_INT_HXX diff --git a/libxsde/xsde/cxx/serializer/non-validating/unsigned-long-long.cxx b/libxsde/xsde/cxx/serializer/non-validating/unsigned-long-long.cxx new file mode 100644 index 0000000..6e62f87 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/unsigned-long-long.cxx @@ -0,0 +1,43 @@ +// file : xsde/cxx/serializer/non-validating/unsigned-long-long.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/non-validating/unsigned-long-long.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + void unsigned_long_simpl:: + pre (unsigned long long value) + { + value_ = value; + } + + void unsigned_long_simpl:: + _serialize_content () + { + // We only need strlen("18446744073709551615") + 1 characters to + // hold all representations of unsigned long long. + // + char str[21]; + +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 21, "%llu", value_); +#else + int n = sprintf (str, "%llu", value_); +#endif + if (n > 0 && n < 21) + _characters (str, static_cast<size_t> (n)); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/unsigned-long-long.hxx b/libxsde/xsde/cxx/serializer/non-validating/unsigned-long-long.hxx new file mode 100644 index 0000000..34ea158 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/unsigned-long-long.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/non-validating/unsigned-long-long.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_NON_VALIDATING_UNSIGNED_LONG_LONG_HXX +#define XSDE_CXX_SERIALIZER_NON_VALIDATING_UNSIGNED_LONG_LONG_HXX + +#include <xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + // 64-bit unsigned integer + // +#ifdef XSDE_REUSE_STYLE_MIXIN + struct unsigned_long_simpl: virtual unsigned_long_sskel +#else + struct unsigned_long_simpl: unsigned_long_sskel +#endif + { + virtual void + pre (unsigned long long); + + virtual void + _serialize_content (); + + protected: + unsigned long long value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_NON_VALIDATING_UNSIGNED_LONG_LONG_HXX diff --git a/libxsde/xsde/cxx/serializer/non-validating/unsigned-long.cxx b/libxsde/xsde/cxx/serializer/non-validating/unsigned-long.cxx new file mode 100644 index 0000000..fd70eaf --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/unsigned-long.cxx @@ -0,0 +1,43 @@ +// file : xsde/cxx/serializer/non-validating/unsigned-long.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/non-validating/unsigned-long.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + void unsigned_long_simpl:: + pre (unsigned long value) + { + value_ = value; + } + + void unsigned_long_simpl:: + _serialize_content () + { + // We only need strlen("18446744073709551615") + 1 characters to + // hold all representations of (possibly 64-bit) unsigned long. + // + char str[21]; + +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 21, "%lu", value_); +#else + int n = sprintf (str, "%lu", value_); +#endif + if (n > 0 && n < 21) + _characters (str, static_cast<size_t> (n)); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/unsigned-long.hxx b/libxsde/xsde/cxx/serializer/non-validating/unsigned-long.hxx new file mode 100644 index 0000000..ba061d3 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/unsigned-long.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/non-validating/unsigned-long.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_NON_VALIDATING_UNSIGNED_LONG_HXX +#define XSDE_CXX_SERIALIZER_NON_VALIDATING_UNSIGNED_LONG_HXX + +#include <xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + // Fall-back implementation when 64 bit long long is not available. + // +#ifdef XSDE_REUSE_STYLE_MIXIN + struct unsigned_long_simpl: virtual unsigned_long_sskel +#else + struct unsigned_long_simpl: unsigned_long_sskel +#endif + { + virtual void + pre (unsigned long); + + virtual void + _serialize_content (); + + protected: + unsigned long value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_NON_VALIDATING_UNSIGNED_LONG_HXX diff --git a/libxsde/xsde/cxx/serializer/non-validating/unsigned-short.cxx b/libxsde/xsde/cxx/serializer/non-validating/unsigned-short.cxx new file mode 100644 index 0000000..ffe29e1 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/unsigned-short.cxx @@ -0,0 +1,43 @@ +// file : xsde/cxx/serializer/non-validating/unsigned-short.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/non-validating/unsigned-short.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + void unsigned_short_simpl:: + pre (unsigned short value) + { + value_ = value; + } + + void unsigned_short_simpl:: + _serialize_content () + { + // We only need strlen("65535") + 1 characters to hold all + // representations of short. + // + char str[6]; + +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 6, "%u", value_); +#else + int n = sprintf (str, "%u", value_); +#endif + if (n > 0 && n < 6) + _characters (str, static_cast<size_t> (n)); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/unsigned-short.hxx b/libxsde/xsde/cxx/serializer/non-validating/unsigned-short.hxx new file mode 100644 index 0000000..ffde97c --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/unsigned-short.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/non-validating/unsigned-short.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_NON_VALIDATING_UNSIGNED_SHORT_HXX +#define XSDE_CXX_SERIALIZER_NON_VALIDATING_UNSIGNED_SHORT_HXX + +#include <xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + // 16-bit unsigned integer + // +#ifdef XSDE_REUSE_STYLE_MIXIN + struct unsigned_short_simpl: virtual unsigned_short_sskel +#else + struct unsigned_short_simpl: unsigned_short_sskel +#endif + { + virtual void + pre (unsigned short); + + virtual void + _serialize_content (); + + protected: + unsigned short value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_NON_VALIDATING_UNSIGNED_SHORT_HXX diff --git a/libxsde/xsde/cxx/serializer/non-validating/uri-stl.cxx b/libxsde/xsde/cxx/serializer/non-validating/uri-stl.cxx new file mode 100644 index 0000000..c109227 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/uri-stl.cxx @@ -0,0 +1,35 @@ +// file : xsde/cxx/serializer/non-validating/uri-stl.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/serializer/non-validating/uri-stl.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + void uri_simpl:: + pre (const std::string& value) + { + value_ = value; + } + + void uri_simpl:: + _serialize_content () + { + // Make sure we don't hold any references to the string. + // + std::string tmp; + tmp.swap (value_); + + _characters (tmp.c_str (), tmp.size ()); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/uri-stl.hxx b/libxsde/xsde/cxx/serializer/non-validating/uri-stl.hxx new file mode 100644 index 0000000..38310e5 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/uri-stl.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/non-validating/uri-stl.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_NON_VALIDATING_URI_STL_HXX +#define XSDE_CXX_SERIALIZER_NON_VALIDATING_URI_STL_HXX + +#include <string> + +#include <xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct uri_simpl: virtual uri_sskel +#else + struct uri_simpl: uri_sskel +#endif + { + virtual void + pre (const std::string&); + + virtual void + _serialize_content (); + + protected: + std::string value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_NON_VALIDATING_URI_STL_HXX diff --git a/libxsde/xsde/cxx/serializer/non-validating/uri.cxx b/libxsde/xsde/cxx/serializer/non-validating/uri.cxx new file mode 100644 index 0000000..372c88d --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/uri.cxx @@ -0,0 +1,43 @@ +// file : xsde/cxx/serializer/non-validating/uri.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/serializer/non-validating/uri.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + uri_simpl:: + ~uri_simpl () + { + if (free_) + delete[] const_cast<char*> (value_); + } + + void uri_simpl:: + pre (const char* value) + { + value_ = value; + } + + void uri_simpl:: + _serialize_content () + { + _characters (value_); + + if (free_) + { + delete[] const_cast<char*> (value_); + value_ = 0; + } + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/uri.hxx b/libxsde/xsde/cxx/serializer/non-validating/uri.hxx new file mode 100644 index 0000000..86a3c47 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/uri.hxx @@ -0,0 +1,47 @@ +// file : xsde/cxx/serializer/non-validating/uri.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_NON_VALIDATING_URI_HXX +#define XSDE_CXX_SERIALIZER_NON_VALIDATING_URI_HXX + +#include <xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct uri_simpl: virtual uri_sskel +#else + struct uri_simpl: uri_sskel +#endif + { + virtual + ~uri_simpl (); + + uri_simpl (bool free = false); + + virtual void + pre (const char*); + + virtual void + _serialize_content (); + + protected: + bool free_; + const char* value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/non-validating/uri.ixx> + +#endif // XSDE_CXX_SERIALIZER_NON_VALIDATING_URI_HXX diff --git a/libxsde/xsde/cxx/serializer/non-validating/uri.ixx b/libxsde/xsde/cxx/serializer/non-validating/uri.ixx new file mode 100644 index 0000000..d9dcd79 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/uri.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/non-validating/uri.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + inline uri_simpl:: + uri_simpl (bool free) + : free_ (free), value_ (0) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/xml-schema-simpl.hxx b/libxsde/xsde/cxx/serializer/non-validating/xml-schema-simpl.hxx new file mode 100644 index 0000000..adda9fd --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/xml-schema-simpl.hxx @@ -0,0 +1,82 @@ +// file : xsde/cxx/serializer/non-validating/xml-schema-simpl.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_NON_VALIDATING_XML_SCHEMA_SIMPL_HXX +#define XSDE_CXX_SERIALIZER_NON_VALIDATING_XML_SCHEMA_SIMPL_HXX + +#include <xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx> + +#include <xsde/cxx/serializer/non-validating/any-type.hxx> +#include <xsde/cxx/serializer/non-validating/boolean.hxx> +#include <xsde/cxx/serializer/non-validating/byte.hxx> +#include <xsde/cxx/serializer/non-validating/unsigned-byte.hxx> +#include <xsde/cxx/serializer/non-validating/byte.hxx> +#include <xsde/cxx/serializer/non-validating/unsigned-byte.hxx> +#include <xsde/cxx/serializer/non-validating/short.hxx> +#include <xsde/cxx/serializer/non-validating/unsigned-short.hxx> +#include <xsde/cxx/serializer/non-validating/int.hxx> +#include <xsde/cxx/serializer/non-validating/unsigned-int.hxx> + +#ifdef XSDE_LONGLONG +# include <xsde/cxx/serializer/non-validating/long-long.hxx> +# include <xsde/cxx/serializer/non-validating/unsigned-long-long.hxx> +#else +# include <xsde/cxx/serializer/non-validating/long.hxx> +# include <xsde/cxx/serializer/non-validating/unsigned-long.hxx> +#endif + +#include <xsde/cxx/serializer/non-validating/integer.hxx> +#include <xsde/cxx/serializer/non-validating/negative-integer.hxx> +#include <xsde/cxx/serializer/non-validating/non-positive-integer.hxx> +#include <xsde/cxx/serializer/non-validating/positive-integer.hxx> +#include <xsde/cxx/serializer/non-validating/non-negative-integer.hxx> +#include <xsde/cxx/serializer/non-validating/float.hxx> +#include <xsde/cxx/serializer/non-validating/double.hxx> +#include <xsde/cxx/serializer/non-validating/decimal.hxx> + +#ifdef XSDE_STL +# include <xsde/cxx/serializer/non-validating/string-stl.hxx> +# include <xsde/cxx/serializer/non-validating/normalized-string-stl.hxx> +# include <xsde/cxx/serializer/non-validating/token-stl.hxx> +# include <xsde/cxx/serializer/non-validating/name-stl.hxx> +# include <xsde/cxx/serializer/non-validating/nmtoken-stl.hxx> +# include <xsde/cxx/serializer/non-validating/nmtokens-stl.hxx> +# include <xsde/cxx/serializer/non-validating/ncname-stl.hxx> +# include <xsde/cxx/serializer/non-validating/id-stl.hxx> +# include <xsde/cxx/serializer/non-validating/idref-stl.hxx> +# include <xsde/cxx/serializer/non-validating/idrefs-stl.hxx> +# include <xsde/cxx/serializer/non-validating/language-stl.hxx> +# include <xsde/cxx/serializer/non-validating/uri-stl.hxx> +# include <xsde/cxx/serializer/non-validating/qname-stl.hxx> +#else +# include <xsde/cxx/serializer/non-validating/string.hxx> +# include <xsde/cxx/serializer/non-validating/normalized-string.hxx> +# include <xsde/cxx/serializer/non-validating/token.hxx> +# include <xsde/cxx/serializer/non-validating/name.hxx> +# include <xsde/cxx/serializer/non-validating/nmtoken.hxx> +# include <xsde/cxx/serializer/non-validating/nmtokens.hxx> +# include <xsde/cxx/serializer/non-validating/ncname.hxx> +# include <xsde/cxx/serializer/non-validating/id.hxx> +# include <xsde/cxx/serializer/non-validating/idref.hxx> +# include <xsde/cxx/serializer/non-validating/idrefs.hxx> +# include <xsde/cxx/serializer/non-validating/language.hxx> +# include <xsde/cxx/serializer/non-validating/uri.hxx> +# include <xsde/cxx/serializer/non-validating/qname.hxx> +#endif + +#include <xsde/cxx/serializer/non-validating/base64-binary.hxx> +#include <xsde/cxx/serializer/non-validating/hex-binary.hxx> + +#include <xsde/cxx/serializer/non-validating/gday.hxx> +#include <xsde/cxx/serializer/non-validating/gmonth.hxx> +#include <xsde/cxx/serializer/non-validating/gyear.hxx> +#include <xsde/cxx/serializer/non-validating/gmonth-day.hxx> +#include <xsde/cxx/serializer/non-validating/gyear-month.hxx> +#include <xsde/cxx/serializer/non-validating/date.hxx> +#include <xsde/cxx/serializer/non-validating/time.hxx> +#include <xsde/cxx/serializer/non-validating/date-time.hxx> +#include <xsde/cxx/serializer/non-validating/duration.hxx> + +#endif // XSDE_CXX_SERIALIZER_NON_VALIDATING_XML_SCHEMA_SIMPL_HXX diff --git a/libxsde/xsde/cxx/serializer/non-validating/xml-schema-sskel.cxx b/libxsde/xsde/cxx/serializer/non-validating/xml-schema-sskel.cxx new file mode 100644 index 0000000..f9bb0b1 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/xml-schema-sskel.cxx @@ -0,0 +1,560 @@ +// file : xsde/cxx/serializer/non-validating/xml-schema-sskel.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + // any_type_sskel + // + void any_type_sskel:: + pre () + { +#ifdef XSDE_REUSE_STYLE_TIEIN + if (any_type_impl_) + any_type_impl_->pre (); +#endif + } + + // any_simple_type_sskel + // + void any_simple_type_sskel:: + pre () + { +#ifdef XSDE_REUSE_STYLE_TIEIN + if (any_simple_type_impl_) + any_simple_type_impl_->pre (); +#endif + } + + // static/dynamic_type function implementations. + // +#ifdef XSDE_POLYMORPHIC + const char* any_type_sskel:: + _static_type () + { + return "anyType http://www.w3.org/2001/XMLSchema"; + } + + const char* any_type_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* any_simple_type_sskel:: + _static_type () + { + return "anySimpleType http://www.w3.org/2001/XMLSchema"; + } + + const char* any_simple_type_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* boolean_sskel:: + _static_type () + { + return "boolean http://www.w3.org/2001/XMLSchema"; + } + + const char* boolean_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* byte_sskel:: + _static_type () + { + return "byte http://www.w3.org/2001/XMLSchema"; + } + + const char* byte_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* unsigned_byte_sskel:: + _static_type () + { + return "unsignedByte http://www.w3.org/2001/XMLSchema"; + } + + const char* unsigned_byte_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* short_sskel:: + _static_type () + { + return "short http://www.w3.org/2001/XMLSchema"; + } + + const char* short_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* unsigned_short_sskel:: + _static_type () + { + return "unsignedShort http://www.w3.org/2001/XMLSchema"; + } + + const char* unsigned_short_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* int_sskel:: + _static_type () + { + return "int http://www.w3.org/2001/XMLSchema"; + } + + const char* int_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* unsigned_int_sskel:: + _static_type () + { + return "unsignedInt http://www.w3.org/2001/XMLSchema"; + } + + const char* unsigned_int_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* long_sskel:: + _static_type () + { + return "long http://www.w3.org/2001/XMLSchema"; + } + + const char* long_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* unsigned_long_sskel:: + _static_type () + { + return "unsignedLong http://www.w3.org/2001/XMLSchema"; + } + + const char* unsigned_long_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* integer_sskel:: + _static_type () + { + return "integer http://www.w3.org/2001/XMLSchema"; + } + + const char* integer_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* negative_integer_sskel:: + _static_type () + { + return "negativeInteger http://www.w3.org/2001/XMLSchema"; + } + + const char* negative_integer_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* non_positive_integer_sskel:: + _static_type () + { + return "nonPositiveInteger http://www.w3.org/2001/XMLSchema"; + } + + const char* non_positive_integer_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* positive_integer_sskel:: + _static_type () + { + return "positiveInteger http://www.w3.org/2001/XMLSchema"; + } + + const char* positive_integer_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* non_negative_integer_sskel:: + _static_type () + { + return "nonNegativeInteger http://www.w3.org/2001/XMLSchema"; + } + + const char* non_negative_integer_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* float_sskel:: + _static_type () + { + return "float http://www.w3.org/2001/XMLSchema"; + } + + const char* float_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* double_sskel:: + _static_type () + { + return "double http://www.w3.org/2001/XMLSchema"; + } + + const char* double_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* decimal_sskel:: + _static_type () + { + return "decimal http://www.w3.org/2001/XMLSchema"; + } + + const char* decimal_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* string_sskel:: + _static_type () + { + return "string http://www.w3.org/2001/XMLSchema"; + } + + const char* string_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* normalized_string_sskel:: + _static_type () + { + return "normalizedString http://www.w3.org/2001/XMLSchema"; + } + + const char* normalized_string_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* token_sskel:: + _static_type () + { + return "token http://www.w3.org/2001/XMLSchema"; + } + + const char* token_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* name_sskel:: + _static_type () + { + return "Name http://www.w3.org/2001/XMLSchema"; + } + + const char* name_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* nmtoken_sskel:: + _static_type () + { + return "NMTOKEN http://www.w3.org/2001/XMLSchema"; + } + + const char* nmtoken_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* nmtokens_sskel:: + _static_type () + { + return "NMTOKENS http://www.w3.org/2001/XMLSchema"; + } + + const char* nmtokens_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* ncname_sskel:: + _static_type () + { + return "NCName http://www.w3.org/2001/XMLSchema"; + } + + const char* ncname_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* id_sskel:: + _static_type () + { + return "ID http://www.w3.org/2001/XMLSchema"; + } + + const char* id_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* idref_sskel:: + _static_type () + { + return "IDREF http://www.w3.org/2001/XMLSchema"; + } + + const char* idref_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* idrefs_sskel:: + _static_type () + { + return "IDREFS http://www.w3.org/2001/XMLSchema"; + } + + const char* idrefs_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* language_sskel:: + _static_type () + { + return "language http://www.w3.org/2001/XMLSchema"; + } + + const char* language_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* uri_sskel:: + _static_type () + { + return "anyURI http://www.w3.org/2001/XMLSchema"; + } + + const char* uri_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* qname_sskel:: + _static_type () + { + return "QName http://www.w3.org/2001/XMLSchema"; + } + + const char* qname_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* base64_binary_sskel:: + _static_type () + { + return "base64Binary http://www.w3.org/2001/XMLSchema"; + } + + const char* base64_binary_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* hex_binary_sskel:: + _static_type () + { + return "hexBinary http://www.w3.org/2001/XMLSchema"; + } + + const char* hex_binary_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* gday_sskel:: + _static_type () + { + return "gDay http://www.w3.org/2001/XMLSchema"; + } + + const char* gday_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* gmonth_sskel:: + _static_type () + { + return "gMonth http://www.w3.org/2001/XMLSchema"; + } + + const char* gmonth_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* gyear_sskel:: + _static_type () + { + return "gYear http://www.w3.org/2001/XMLSchema"; + } + + const char* gyear_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* gmonth_day_sskel:: + _static_type () + { + return "gMonthDay http://www.w3.org/2001/XMLSchema"; + } + + const char* gmonth_day_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* gyear_month_sskel:: + _static_type () + { + return "gYearMonth http://www.w3.org/2001/XMLSchema"; + } + + const char* gyear_month_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* date_sskel:: + _static_type () + { + return "date http://www.w3.org/2001/XMLSchema"; + } + + const char* date_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* time_sskel:: + _static_type () + { + return "time http://www.w3.org/2001/XMLSchema"; + } + + const char* time_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* date_time_sskel:: + _static_type () + { + return "dateTime http://www.w3.org/2001/XMLSchema"; + } + + const char* date_time_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* duration_sskel:: + _static_type () + { + return "duration http://www.w3.org/2001/XMLSchema"; + } + + const char* duration_sskel:: + _dynamic_type () const + { + return _static_type (); + } +#endif // XSDE_POLYMORPHIC + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx b/libxsde/xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx new file mode 100644 index 0000000..9365f03 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx @@ -0,0 +1,1382 @@ +// file : xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_NON_VALIDATING_XML_SCHEMA_SSKEL_HXX +#define XSDE_CXX_SERIALIZER_NON_VALIDATING_XML_SCHEMA_SSKEL_HXX + +#include <xsde/cxx/config.hxx> + +#ifdef XSDE_STL +# include <string> +#endif + +#include <xsde/cxx/serializer/xml-schema.hxx> + +#include <xsde/cxx/serializer/non-validating/serializer.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + // anyType and anySimpleType. + // + struct any_type_sskel: complex_content + { + virtual void + pre (); + + // Override the following two functions to implement + // your logic. + // + + // virtual void + // _serialize_attributes (); + + // virtual void + // _serialize_content (); + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + any_type_sskel (); + any_type_sskel (any_type_sskel* impl, void*); + + protected: + any_type_sskel* any_type_impl_; +#endif + }; + + struct any_simple_type_sskel: simple_content + { + virtual void + pre (); + + // Override the following function to implement your + // logic. + // + + // virtual void + // _serialize_content (); + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + any_simple_type_sskel (); + any_simple_type_sskel (any_simple_type_sskel* impl, void*); + + protected: + any_simple_type_sskel* any_simple_type_impl_; +#endif + }; + + // Boolean. + // + struct boolean_sskel: simple_content + { + virtual void + pre (bool) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + boolean_sskel (); + boolean_sskel (boolean_sskel* impl, void*); + + protected: + boolean_sskel* boolean_impl_; +#endif + }; + + // 8-bit + // + + struct byte_sskel: simple_content + { + virtual void + pre (signed char) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + byte_sskel (); + byte_sskel (byte_sskel* impl, void*); + + protected: + byte_sskel* byte_impl_; +#endif + }; + + struct unsigned_byte_sskel: simple_content + { + virtual void + pre (unsigned char) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + unsigned_byte_sskel (); + unsigned_byte_sskel (unsigned_byte_sskel* impl, void*); + + protected: + unsigned_byte_sskel* unsigned_byte_impl_; +#endif + }; + + + // 16-bit + // + + struct short_sskel: simple_content + { + virtual void + pre (short) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + short_sskel (); + short_sskel (short_sskel* impl, void*); + + protected: + short_sskel* short_impl_; +#endif + }; + + struct unsigned_short_sskel: simple_content + { + virtual void + pre (unsigned short) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + unsigned_short_sskel (); + unsigned_short_sskel (unsigned_short_sskel* impl, void*); + + protected: + unsigned_short_sskel* unsigned_short_impl_; +#endif + }; + + // 32-bit + // + + struct int_sskel: simple_content + { + virtual void + pre (int) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + int_sskel (); + int_sskel (int_sskel* impl, void*); + + protected: + int_sskel* int_impl_; +#endif + }; + + struct unsigned_int_sskel: simple_content + { + virtual void + pre (unsigned int) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + unsigned_int_sskel (); + unsigned_int_sskel (unsigned_int_sskel* impl, void*); + + protected: + unsigned_int_sskel* unsigned_int_impl_; +#endif + }; + + // 64-bit + // + +#ifdef XSDE_LONGLONG + struct long_sskel: simple_content + { + virtual void + pre (long long) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + long_sskel (); + long_sskel (long_sskel* impl, void*); + + protected: + long_sskel* long_impl_; +#endif + }; + + struct unsigned_long_sskel: simple_content + { + virtual void + pre (unsigned long long) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + unsigned_long_sskel (); + unsigned_long_sskel (unsigned_long_sskel* impl, void*); + + protected: + unsigned_long_sskel* unsigned_long_impl_; +#endif + }; +#else + struct long_sskel: simple_content + { + virtual void + pre (long) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + long_sskel (); + long_sskel (long_sskel* impl, void*); + + protected: + long_sskel* long_impl_; +#endif + }; + + struct unsigned_long_sskel: simple_content + { + virtual void + pre (unsigned long) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + unsigned_long_sskel (); + unsigned_long_sskel (unsigned_long_sskel* impl, void*); + + protected: + unsigned_long_sskel* unsigned_long_impl_; +#endif + }; +#endif + + // Arbitrary-length integers. + // + + struct integer_sskel: simple_content + { + virtual void + pre (long) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + integer_sskel (); + integer_sskel (integer_sskel* impl, void*); + + protected: + integer_sskel* integer_impl_; +#endif + }; + + struct negative_integer_sskel: simple_content + { + virtual void + pre (long) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + negative_integer_sskel (); + negative_integer_sskel (negative_integer_sskel* impl, void*); + + protected: + negative_integer_sskel* negative_integer_impl_; +#endif + }; + + struct non_positive_integer_sskel: simple_content + { + virtual void + pre (long) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + non_positive_integer_sskel (); + non_positive_integer_sskel (non_positive_integer_sskel* impl, void*); + + protected: + non_positive_integer_sskel* non_positive_integer_impl_; +#endif + }; + + struct positive_integer_sskel: simple_content + { + virtual void + pre (unsigned long) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + positive_integer_sskel (); + positive_integer_sskel (positive_integer_sskel* impl, void*); + + protected: + positive_integer_sskel* positive_integer_impl_; +#endif + }; + + struct non_negative_integer_sskel: simple_content + { + virtual void + pre (unsigned long) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + non_negative_integer_sskel (); + non_negative_integer_sskel (non_negative_integer_sskel* impl, void*); + + protected: + non_negative_integer_sskel* non_negative_integer_impl_; +#endif + }; + + // Floats. + // + + struct float_sskel: simple_content + { + virtual void + pre (float) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + float_sskel (); + float_sskel (float_sskel* impl, void*); + + protected: + float_sskel* float_impl_; +#endif + }; + + struct double_sskel: simple_content + { + virtual void + pre (double) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + double_sskel (); + double_sskel (double_sskel* impl, void*); + + protected: + double_sskel* double_impl_; +#endif + }; + + struct decimal_sskel: simple_content + { + virtual void + pre (double) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + decimal_sskel (); + decimal_sskel (decimal_sskel* impl, void*); + + protected: + decimal_sskel* decimal_impl_; +#endif + }; + + // String-based types. + // +#ifdef XSDE_STL + + struct string_sskel: simple_content + { + virtual void + pre (const std::string&) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + string_sskel (); + string_sskel (string_sskel* impl, void*); + + protected: + string_sskel* string_impl_; +#endif + }; + +#ifdef XSDE_REUSE_STYLE_MIXIN + struct normalized_string_sskel: virtual string_sskel +#else + struct normalized_string_sskel: string_sskel +#endif + { +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + normalized_string_sskel (); + normalized_string_sskel (normalized_string_sskel* impl, void*); + + protected: + normalized_string_sskel* normalized_string_impl_; +#endif + }; + +#ifdef XSDE_REUSE_STYLE_MIXIN + struct token_sskel: virtual normalized_string_sskel +#else + struct token_sskel: normalized_string_sskel +#endif + { +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + token_sskel (); + token_sskel (token_sskel* impl, void*); + + protected: + token_sskel* token_impl_; +#endif + }; + +#ifdef XSDE_REUSE_STYLE_MIXIN + struct name_sskel: virtual token_sskel +#else + struct name_sskel: token_sskel +#endif + { +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + name_sskel (); + name_sskel (name_sskel* impl, void*); + + protected: + name_sskel* name_impl_; +#endif + }; + +#ifdef XSDE_REUSE_STYLE_MIXIN + struct nmtoken_sskel: virtual token_sskel +#else + struct nmtoken_sskel: token_sskel +#endif + { +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + nmtoken_sskel (); + nmtoken_sskel (nmtoken_sskel* impl, void*); + + protected: + nmtoken_sskel* nmtoken_impl_; +#endif + }; + + struct nmtokens_sskel: simple_content + { + virtual void + pre (const string_sequence*) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + nmtokens_sskel (); + nmtokens_sskel (nmtokens_sskel* impl, void*); + + protected: + nmtokens_sskel* nmtokens_impl_; +#endif + }; + +#ifdef XSDE_REUSE_STYLE_MIXIN + struct ncname_sskel: virtual name_sskel +#else + struct ncname_sskel: name_sskel +#endif + { +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + ncname_sskel (); + ncname_sskel (ncname_sskel* impl, void*); + + protected: + ncname_sskel* ncname_impl_; +#endif + }; + +#ifdef XSDE_REUSE_STYLE_MIXIN + struct id_sskel: virtual ncname_sskel +#else + struct id_sskel: ncname_sskel +#endif + { +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + id_sskel (); + id_sskel (id_sskel* impl, void*); + + protected: + id_sskel* id_impl_; +#endif + }; + +#ifdef XSDE_REUSE_STYLE_MIXIN + struct idref_sskel: virtual ncname_sskel +#else + struct idref_sskel: ncname_sskel +#endif + { +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + idref_sskel (); + idref_sskel (idref_sskel* impl, void*); + + protected: + idref_sskel* idref_impl_; +#endif + }; + + struct idrefs_sskel: simple_content + { + virtual void + pre (const string_sequence*) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + idrefs_sskel (); + idrefs_sskel (idrefs_sskel* impl, void*); + + protected: + idrefs_sskel* idrefs_impl_; +#endif + }; + +#ifdef XSDE_REUSE_STYLE_MIXIN + struct language_sskel: virtual token_sskel +#else + struct language_sskel: token_sskel +#endif + { +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + language_sskel (); + language_sskel (language_sskel* impl, void*); + + protected: + language_sskel* language_impl_; +#endif + }; + + struct uri_sskel: simple_content + { + virtual void + pre (const std::string&) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + uri_sskel (); + uri_sskel (uri_sskel* impl, void*); + + protected: + uri_sskel* uri_impl_; +#endif + }; + + struct qname_sskel: simple_content + { + virtual void + pre (const qname&) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + qname_sskel (); + qname_sskel (qname_sskel* impl, void*); + + protected: + qname_sskel* qname_impl_; +#endif + }; + +#else // XSDE_STL + + struct string_sskel: simple_content + { + virtual void + pre (const char*) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + string_sskel (); + string_sskel (string_sskel* impl, void*); + + protected: + string_sskel* string_impl_; +#endif + }; + +#ifdef XSDE_REUSE_STYLE_MIXIN + struct normalized_string_sskel: virtual string_sskel +#else + struct normalized_string_sskel: string_sskel +#endif + { +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + normalized_string_sskel (); + normalized_string_sskel (normalized_string_sskel* impl, void*); + + protected: + normalized_string_sskel* normalized_string_impl_; +#endif + }; + +#ifdef XSDE_REUSE_STYLE_MIXIN + struct token_sskel: virtual normalized_string_sskel +#else + struct token_sskel: normalized_string_sskel +#endif + { +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + token_sskel (); + token_sskel (token_sskel* impl, void*); + + protected: + token_sskel* token_impl_; +#endif + }; + +#ifdef XSDE_REUSE_STYLE_MIXIN + struct name_sskel: virtual token_sskel +#else + struct name_sskel: token_sskel +#endif + { +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + name_sskel (); + name_sskel (name_sskel* impl, void*); + + protected: + name_sskel* name_impl_; +#endif + }; + +#ifdef XSDE_REUSE_STYLE_MIXIN + struct nmtoken_sskel: virtual token_sskel +#else + struct nmtoken_sskel: token_sskel +#endif + { +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + nmtoken_sskel (); + nmtoken_sskel (nmtoken_sskel* impl, void*); + + protected: + nmtoken_sskel* nmtoken_impl_; +#endif + }; + + struct nmtokens_sskel: simple_content + { + virtual void + pre (const string_sequence*) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + nmtokens_sskel (); + nmtokens_sskel (nmtokens_sskel* impl, void*); + + protected: + nmtokens_sskel* nmtokens_impl_; +#endif + }; + +#ifdef XSDE_REUSE_STYLE_MIXIN + struct ncname_sskel: virtual name_sskel +#else + struct ncname_sskel: name_sskel +#endif + { +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + ncname_sskel (); + ncname_sskel (ncname_sskel* impl, void*); + + protected: + ncname_sskel* ncname_impl_; +#endif + }; + +#ifdef XSDE_REUSE_STYLE_MIXIN + struct id_sskel: virtual ncname_sskel +#else + struct id_sskel: ncname_sskel +#endif + { +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + id_sskel (); + id_sskel (id_sskel* impl, void*); + + protected: + id_sskel* id_impl_; +#endif + }; + +#ifdef XSDE_REUSE_STYLE_MIXIN + struct idref_sskel: virtual ncname_sskel +#else + struct idref_sskel: ncname_sskel +#endif + { +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + idref_sskel (); + idref_sskel (idref_sskel* impl, void*); + + protected: + idref_sskel* idref_impl_; +#endif + }; + + struct idrefs_sskel: simple_content + { + virtual void + pre (const string_sequence*) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + idrefs_sskel (); + idrefs_sskel (idrefs_sskel* impl, void*); + + protected: + idrefs_sskel* idrefs_impl_; +#endif + }; + +#ifdef XSDE_REUSE_STYLE_MIXIN + struct language_sskel: virtual token_sskel +#else + struct language_sskel: token_sskel +#endif + { +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + language_sskel (); + language_sskel (language_sskel* impl, void*); + + protected: + language_sskel* language_impl_; +#endif + }; + + struct uri_sskel: simple_content + { + virtual void + pre (const char*) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + uri_sskel (); + uri_sskel (uri_sskel* impl, void*); + + protected: + uri_sskel* uri_impl_; +#endif + }; + + struct qname_sskel: simple_content + { + virtual void + pre (const qname*) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + qname_sskel (); + qname_sskel (qname_sskel* impl, void*); + + protected: + qname_sskel* qname_impl_; +#endif + }; + +#endif // XSDE_STL + + + // base64Binary + // + struct base64_binary_sskel: simple_content + { + virtual void + pre (const buffer*) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + base64_binary_sskel (); + base64_binary_sskel (base64_binary_sskel* impl, void*); + + protected: + base64_binary_sskel* base64_binary_impl_; +#endif + }; + + // hexBinary + // + struct hex_binary_sskel: simple_content + { + virtual void + pre (const buffer*) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + hex_binary_sskel (); + hex_binary_sskel (hex_binary_sskel* impl, void*); + + protected: + hex_binary_sskel* hex_binary_impl_; +#endif + }; + + // Time and date types. + // + struct gday_sskel: simple_content + { + virtual void + pre (const gday&) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + gday_sskel (); + gday_sskel (gday_sskel* impl, void*); + + protected: + gday_sskel* gday_impl_; +#endif + }; + + struct gmonth_sskel: simple_content + { + virtual void + pre (const gmonth&) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + gmonth_sskel (); + gmonth_sskel (gmonth_sskel* impl, void*); + + protected: + gmonth_sskel* gmonth_impl_; +#endif + }; + + struct gyear_sskel: simple_content + { + virtual void + pre (const gyear&) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + gyear_sskel (); + gyear_sskel (gyear_sskel* impl, void*); + + protected: + gyear_sskel* gyear_impl_; +#endif + }; + + struct gmonth_day_sskel: simple_content + { + virtual void + pre (const gmonth_day&) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + gmonth_day_sskel (); + gmonth_day_sskel (gmonth_day_sskel* impl, void*); + + protected: + gmonth_day_sskel* gmonth_day_impl_; +#endif + }; + + struct gyear_month_sskel: simple_content + { + virtual void + pre (const gyear_month&) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + gyear_month_sskel (); + gyear_month_sskel (gyear_month_sskel* impl, void*); + + protected: + gyear_month_sskel* gyear_month_impl_; +#endif + }; + + struct date_sskel: simple_content + { + virtual void + pre (const date&) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + date_sskel (); + date_sskel (date_sskel* impl, void*); + + protected: + date_sskel* date_impl_; +#endif + }; + + struct time_sskel: simple_content + { + virtual void + pre (const time&) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + time_sskel (); + time_sskel (time_sskel* impl, void*); + + protected: + time_sskel* time_impl_; +#endif + }; + + struct date_time_sskel: simple_content + { + virtual void + pre (const date_time&) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + date_time_sskel (); + date_time_sskel (date_time_sskel* impl, void*); + + protected: + date_time_sskel* date_time_impl_; +#endif + }; + + struct duration_sskel: simple_content + { + virtual void + pre (const duration&) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + duration_sskel (); + duration_sskel (duration_sskel* impl, void*); + + protected: + duration_sskel* duration_impl_; +#endif + }; + } + } + } +} + +#include <xsde/cxx/serializer/non-validating/xml-schema-sskel.ixx> + +#endif // XSDE_CXX_SERIALIZER_NON_VALIDATING_XML_SCHEMA_SSKEL_HXX diff --git a/libxsde/xsde/cxx/serializer/non-validating/xml-schema-sskel.ixx b/libxsde/xsde/cxx/serializer/non-validating/xml-schema-sskel.ixx new file mode 100644 index 0000000..de78f5d --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/xml-schema-sskel.ixx @@ -0,0 +1,704 @@ +// file : xsde/cxx/serializer/non-validating/xml-schema-sskel.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + // any_type_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline any_type_sskel:: + any_type_sskel () + : any_type_impl_ (0) + { + } + + inline any_type_sskel:: + any_type_sskel (any_type_sskel* impl, void*) + : complex_content (impl, 0), any_type_impl_ (impl) + { + } +#endif + + // any_simple_type_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline any_simple_type_sskel:: + any_simple_type_sskel () + : any_simple_type_impl_ (0) + { + } + + inline any_simple_type_sskel:: + any_simple_type_sskel (any_simple_type_sskel* impl, void*) + : simple_content (impl, 0), any_simple_type_impl_ (impl) + { + } +#endif + + // boolean_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline boolean_sskel:: + boolean_sskel () + : boolean_impl_ (0) + { + } + + inline boolean_sskel:: + boolean_sskel (boolean_sskel* impl, void*) + : simple_content (impl, 0), boolean_impl_ (impl) + { + } +#endif + + // byte_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline byte_sskel:: + byte_sskel () + : byte_impl_ (0) + { + } + + inline byte_sskel:: + byte_sskel (byte_sskel* impl, void*) + : simple_content (impl, 0), byte_impl_ (impl) + { + } +#endif + + // unsigned_byte_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline unsigned_byte_sskel:: + unsigned_byte_sskel () + : unsigned_byte_impl_ (0) + { + } + + inline unsigned_byte_sskel:: + unsigned_byte_sskel (unsigned_byte_sskel* impl, void*) + : simple_content (impl, 0), unsigned_byte_impl_ (impl) + { + } +#endif + + // short_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline short_sskel:: + short_sskel () + : short_impl_ (0) + { + } + + inline short_sskel:: + short_sskel (short_sskel* impl, void*) + : simple_content (impl, 0), short_impl_ (impl) + { + } +#endif + + // unsigned_short_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline unsigned_short_sskel:: + unsigned_short_sskel () + : unsigned_short_impl_ (0) + { + } + + inline unsigned_short_sskel:: + unsigned_short_sskel (unsigned_short_sskel* impl, void*) + : simple_content (impl, 0), unsigned_short_impl_ (impl) + { + } +#endif + + // int_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline int_sskel:: + int_sskel () + : int_impl_ (0) + { + } + + inline int_sskel:: + int_sskel (int_sskel* impl, void*) + : simple_content (impl, 0), int_impl_ (impl) + { + } +#endif + + // unsigned_int_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline unsigned_int_sskel:: + unsigned_int_sskel () + : unsigned_int_impl_ (0) + { + } + + inline unsigned_int_sskel:: + unsigned_int_sskel (unsigned_int_sskel* impl, void*) + : simple_content (impl, 0), unsigned_int_impl_ (impl) + { + } +#endif + + // long_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline long_sskel:: + long_sskel () + : long_impl_ (0) + { + } + + inline long_sskel:: + long_sskel (long_sskel* impl, void*) + : simple_content (impl, 0), long_impl_ (impl) + { + } +#endif + + // unsigned_long_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline unsigned_long_sskel:: + unsigned_long_sskel () + : unsigned_long_impl_ (0) + { + } + + inline unsigned_long_sskel:: + unsigned_long_sskel (unsigned_long_sskel* impl, void*) + : simple_content (impl, 0), unsigned_long_impl_ (impl) + { + } +#endif + + // integer_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline integer_sskel:: + integer_sskel () + : integer_impl_ (0) + { + } + + inline integer_sskel:: + integer_sskel (integer_sskel* impl, void*) + : simple_content (impl, 0), integer_impl_ (impl) + { + } +#endif + + // negative_integer_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline negative_integer_sskel:: + negative_integer_sskel () + : negative_integer_impl_ (0) + { + } + + inline negative_integer_sskel:: + negative_integer_sskel (negative_integer_sskel* impl, void*) + : simple_content (impl, 0), negative_integer_impl_ (impl) + { + } +#endif + + // non_positive_integer_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline non_positive_integer_sskel:: + non_positive_integer_sskel () + : non_positive_integer_impl_ (0) + { + } + + inline non_positive_integer_sskel:: + non_positive_integer_sskel (non_positive_integer_sskel* impl, void*) + : simple_content (impl, 0), non_positive_integer_impl_ (impl) + { + } +#endif + + // positive_integer_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline positive_integer_sskel:: + positive_integer_sskel () + : positive_integer_impl_ (0) + { + } + + inline positive_integer_sskel:: + positive_integer_sskel (positive_integer_sskel* impl, void*) + : simple_content (impl, 0), positive_integer_impl_ (impl) + { + } +#endif + + // non_negative_integer_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline non_negative_integer_sskel:: + non_negative_integer_sskel () + : non_negative_integer_impl_ (0) + { + } + + inline non_negative_integer_sskel:: + non_negative_integer_sskel (non_negative_integer_sskel* impl, void*) + : simple_content (impl, 0), non_negative_integer_impl_ (impl) + { + } +#endif + + // float_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline float_sskel:: + float_sskel () + : float_impl_ (0) + { + } + + inline float_sskel:: + float_sskel (float_sskel* impl, void*) + : simple_content (impl, 0), float_impl_ (impl) + { + } +#endif + + // double_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline double_sskel:: + double_sskel () + : double_impl_ (0) + { + } + + inline double_sskel:: + double_sskel (double_sskel* impl, void*) + : simple_content (impl, 0), double_impl_ (impl) + { + } +#endif + + // decimal_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline decimal_sskel:: + decimal_sskel () + : decimal_impl_ (0) + { + } + + inline decimal_sskel:: + decimal_sskel (decimal_sskel* impl, void*) + : simple_content (impl, 0), decimal_impl_ (impl) + { + } +#endif + + // string_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline string_sskel:: + string_sskel () + : string_impl_ (0) + { + } + + inline string_sskel:: + string_sskel (string_sskel* impl, void*) + : simple_content (impl, 0), string_impl_ (impl) + { + } +#endif + + // normalized_string_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline normalized_string_sskel:: + normalized_string_sskel () + : normalized_string_impl_ (0) + { + } + + inline normalized_string_sskel:: + normalized_string_sskel (normalized_string_sskel* impl, void*) + : string_sskel (impl, 0), normalized_string_impl_ (impl) + { + } +#endif + + // token_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline token_sskel:: + token_sskel () + : token_impl_ (0) + { + } + + inline token_sskel:: + token_sskel (token_sskel* impl, void*) + : normalized_string_sskel (impl, 0), token_impl_ (impl) + { + } +#endif + + // name_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline name_sskel:: + name_sskel () + : name_impl_ (0) + { + } + + inline name_sskel:: + name_sskel (name_sskel* impl, void*) + : token_sskel (impl, 0), name_impl_ (impl) + { + } +#endif + + // nmtoken_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline nmtoken_sskel:: + nmtoken_sskel () + : nmtoken_impl_ (0) + { + } + + inline nmtoken_sskel:: + nmtoken_sskel (nmtoken_sskel* impl, void*) + : token_sskel (impl, 0), nmtoken_impl_ (impl) + { + } +#endif + + // nmtokens_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline nmtokens_sskel:: + nmtokens_sskel () + : nmtokens_impl_ (0) + { + } + + inline nmtokens_sskel:: + nmtokens_sskel (nmtokens_sskel* impl, void*) + : simple_content (impl, 0), nmtokens_impl_ (impl) + { + } +#endif + + // ncname_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline ncname_sskel:: + ncname_sskel () + : ncname_impl_ (0) + { + } + + inline ncname_sskel:: + ncname_sskel (ncname_sskel* impl, void*) + : name_sskel (impl, 0), ncname_impl_ (impl) + { + } +#endif + + // id_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline id_sskel:: + id_sskel () + : id_impl_ (0) + { + } + + inline id_sskel:: + id_sskel (id_sskel* impl, void*) + : ncname_sskel (impl, 0), id_impl_ (impl) + { + } +#endif + + // idref_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline idref_sskel:: + idref_sskel () + : idref_impl_ (0) + { + } + + inline idref_sskel:: + idref_sskel (idref_sskel* impl, void*) + : ncname_sskel (impl, 0), idref_impl_ (impl) + { + } +#endif + + // idrefs_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline idrefs_sskel:: + idrefs_sskel () + : idrefs_impl_ (0) + { + } + + inline idrefs_sskel:: + idrefs_sskel (idrefs_sskel* impl, void*) + : simple_content (impl, 0), idrefs_impl_ (impl) + { + } +#endif + + // language_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline language_sskel:: + language_sskel () + : language_impl_ (0) + { + } + + inline language_sskel:: + language_sskel (language_sskel* impl, void*) + : token_sskel (impl, 0), language_impl_ (impl) + { + } +#endif + + // uri_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline uri_sskel:: + uri_sskel () + : uri_impl_ (0) + { + } + + inline uri_sskel:: + uri_sskel (uri_sskel* impl, void*) + : simple_content (impl, 0), uri_impl_ (impl) + { + } +#endif + + // qname_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline qname_sskel:: + qname_sskel () + : qname_impl_ (0) + { + } + + inline qname_sskel:: + qname_sskel (qname_sskel* impl, void*) + : simple_content (impl, 0), qname_impl_ (impl) + { + } +#endif + + // base64_binary_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline base64_binary_sskel:: + base64_binary_sskel () + : base64_binary_impl_ (0) + { + } + + inline base64_binary_sskel:: + base64_binary_sskel (base64_binary_sskel* impl, void*) + : simple_content (impl, 0), base64_binary_impl_ (impl) + { + } +#endif + + // hex_binary_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline hex_binary_sskel:: + hex_binary_sskel () + : hex_binary_impl_ (0) + { + } + + inline hex_binary_sskel:: + hex_binary_sskel (hex_binary_sskel* impl, void*) + : simple_content (impl, 0), hex_binary_impl_ (impl) + { + } +#endif + + // gday_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline gday_sskel:: + gday_sskel () + : gday_impl_ (0) + { + } + + inline gday_sskel:: + gday_sskel (gday_sskel* impl, void*) + : simple_content (impl, 0), gday_impl_ (impl) + { + } +#endif + + // gmonth_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline gmonth_sskel:: + gmonth_sskel () + : gmonth_impl_ (0) + { + } + + inline gmonth_sskel:: + gmonth_sskel (gmonth_sskel* impl, void*) + : simple_content (impl, 0), gmonth_impl_ (impl) + { + } +#endif + + // gyear_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline gyear_sskel:: + gyear_sskel () + : gyear_impl_ (0) + { + } + + inline gyear_sskel:: + gyear_sskel (gyear_sskel* impl, void*) + : simple_content (impl, 0), gyear_impl_ (impl) + { + } +#endif + + // gmonth_day_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline gmonth_day_sskel:: + gmonth_day_sskel () + : gmonth_day_impl_ (0) + { + } + + inline gmonth_day_sskel:: + gmonth_day_sskel (gmonth_day_sskel* impl, void*) + : simple_content (impl, 0), gmonth_day_impl_ (impl) + { + } +#endif + + // gyear_month_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline gyear_month_sskel:: + gyear_month_sskel () + : gyear_month_impl_ (0) + { + } + + inline gyear_month_sskel:: + gyear_month_sskel (gyear_month_sskel* impl, void*) + : simple_content (impl, 0), gyear_month_impl_ (impl) + { + } +#endif + + // date_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline date_sskel:: + date_sskel () + : date_impl_ (0) + { + } + + inline date_sskel:: + date_sskel (date_sskel* impl, void*) + : simple_content (impl, 0), date_impl_ (impl) + { + } +#endif + + // time_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline time_sskel:: + time_sskel () + : time_impl_ (0) + { + } + + inline time_sskel:: + time_sskel (time_sskel* impl, void*) + : simple_content (impl, 0), time_impl_ (impl) + { + } +#endif + + // date_time_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline date_time_sskel:: + date_time_sskel () + : date_time_impl_ (0) + { + } + + inline date_time_sskel:: + date_time_sskel (date_time_sskel* impl, void*) + : simple_content (impl, 0), date_time_impl_ (impl) + { + } +#endif + + // duration_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline duration_sskel:: + duration_sskel () + : duration_impl_ (0) + { + } + + inline duration_sskel:: + duration_sskel (duration_sskel* impl, void*) + : simple_content (impl, 0), duration_impl_ (impl) + { + } +#endif + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/substitution-map-load.hxx b/libxsde/xsde/cxx/serializer/substitution-map-load.hxx new file mode 100644 index 0000000..95083e2 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/substitution-map-load.hxx @@ -0,0 +1,40 @@ +// file : xsde/cxx/serializer/substitution-map-load.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_SUBSTITUTION_MAP_LOAD_HXX +#define XSDE_CXX_SERIALIZER_SUBSTITUTION_MAP_LOAD_HXX + +#include <stddef.h> // size_t + +#include <xsde/cxx/config.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + size_t + serializer_smap_elements (); + + inline size_t + serializer_smap_buckets () + { + return XSDE_SERIALIZER_SMAP_BUCKETS; + } + + size_t + serializer_smap_bucket_elements (); + + inline size_t + serializer_smap_bucket_buckets () + { + return XSDE_SERIALIZER_SMAP_BUCKET_BUCKETS; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_SUBSTITUTION_MAP_LOAD_HXX diff --git a/libxsde/xsde/cxx/serializer/substitution-map.cxx b/libxsde/xsde/cxx/serializer/substitution-map.cxx new file mode 100644 index 0000000..e155882 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/substitution-map.cxx @@ -0,0 +1,248 @@ +// file : xsde/cxx/serializer/substitution-map.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/config.hxx> + +#include <string.h> // strlen, strcmp, strncmp + +#ifndef XSDE_EXCEPTIONS +# include <assert.h> // assert +# include <stdlib.h> // exit +#endif + +#include <xsde/cxx/serializer/substitution-map.hxx> +#include <xsde/cxx/serializer/substitution-map-load.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + substitution_map* substitution_map_init::map = 0; + size_t substitution_map_init::count = 0; + + substitution_map:: + ~substitution_map () + { + for (const_iterator i (begin ()), e (end ()); i != e; ++i) + { + delete *static_cast<hashmap**> (const_cast<void*> (*i)); + } + } + + void substitution_map:: + insert (const char* root, + const char* member_ns, + const char* member_name, + const char* member_type) + { + hashmap* m; + + if (const void* p = find (root)) + m = *static_cast<hashmap**> (const_cast<void*> (p)); + else + { + m = new hashmap (XSDE_SERIALIZER_SMAP_BUCKET_BUCKETS, + sizeof (value)); + +#ifndef XSDE_EXCEPTIONS + if (m == 0 || m->_error () != hashmap::error_none) + { + error_ = error_no_memory; + return; + } +#endif + hashmap::insert (root, &m); + +#ifndef XSDE_EXCEPTIONS + if (_error () != error_none) + return; +#endif + } + + value v; + v.ns_ = member_ns; + v.name_ = member_name; + m->insert (member_type, &v); + +#ifndef XSDE_EXCEPTIONS + if (m->_error () != hashmap::error_none) + error_ = error_no_memory; +#endif + } + + bool substitution_map:: + check_ (const char*& ns, + const char*& name, + const char* type) const + { + size_t h = hash (name); + + if (ns) + { + h = hash (h, " ", 1); + h = hash (h, ns); + } + + const bucket* p = find (h); + + if (p == 0) + return false; + + // Search for the entry in the bucket. + // + const size_t el_size = sizeof (element) + sizeof (hashmap*); + const char* b = reinterpret_cast<const char*> (p) + sizeof (bucket); + const char* e = b + p->size_ * el_size; + + size_t nl = ns ? strlen (name) : 0; + + for (; b < e; b += el_size) + { + const element* e = reinterpret_cast<const element*> (b); + + if (e->hash_ == h) + { + if (ns == 0) + { + if (strcmp (e->key_, name) == 0) + break; + } + else + { + if (strncmp (e->key_, name, nl) == 0 && + e->key_[nl] == ' ' && + strcmp (e->key_ + nl + 1, ns) == 0) + break; + } + } + } + + if (b == e) + return false; + + const hashmap* map = *reinterpret_cast<const hashmap* const*> ( + b + sizeof (element)); + + // See if we have a direct substitution. + // + if (const value* v = static_cast<const value*> (map->find (type))) + { + ns = v->ns_; + name = v->name_; + return true; + } + + // Otherwise we have to iterate over possible substitutions and + // see if any of them can in turn be substituted with something + // that we can use. + // + for (const_iterator i (map->begin ()), end (map->end ()); + i != end; ++i) + { + const value* v = static_cast<const value*> (*i); + + const char* tns = v->ns_; + const char* tn = v->name_; + + if (check_ (tns, tn, type)) + { + ns = tns; + name = tn; + return true; + } + } + + return false; + } + + // substitution_map_init + // + substitution_map_init:: + substitution_map_init () + { + if (count == 0) + { + map = new substitution_map (XSDE_SERIALIZER_SMAP_BUCKETS); + +#ifndef XSDE_EXCEPTIONS + if (map == 0 || map->_error () != substitution_map::error_none) + { + // This is static initialization so there is nothing we can do. + // The best thing is to fail fast. abort() would have probably + // been the better choice here but it is not available on some + // platforms (notably, WinCE). + // + assert (false); + exit (1); + } +#endif + } + + ++count; + } + + substitution_map_init:: + ~substitution_map_init () + { + if (--count == 0) + delete map; + } + + // substitution_map_entry + // + substitution_map_entry:: + substitution_map_entry (const char* root, + const char* member_ns, + const char* member_name, + const char* member_type) + { + substitution_map& m = substitution_map_instance (); + m.insert (root, member_ns, member_name, member_type); + +#ifndef XSDE_EXCEPTIONS + if (m._error () != substitution_map::error_none) + { + // This is static initialization so there is nothing we can do. + // The best thing is to fail fast. abort() would have probably + // been the better choice here but it is not available on some + // platforms (notably, WinCE). + // + assert (false); + exit (1); + } +#endif + } + + // + // + size_t + serializer_smap_elements () + { + return substitution_map_instance ().size (); + } + + size_t + serializer_smap_bucket_elements () + { + size_t r = 0; + + substitution_map& m = substitution_map_instance (); + + for (substitution_map::const_iterator i (m.begin ()), e (m.end ()); + i != e; ++i) + { + const hashmap* h = *static_cast<const hashmap* const*> (*i); + + if (h->size () > r) + r = h->size (); + } + + return r; + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/substitution-map.hxx b/libxsde/xsde/cxx/serializer/substitution-map.hxx new file mode 100644 index 0000000..601f255 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/substitution-map.hxx @@ -0,0 +1,88 @@ +// file : xsde/cxx/serializer/substitution-map.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_SUBSTITUTION_MAP_HXX +#define XSDE_CXX_SERIALIZER_SUBSTITUTION_MAP_HXX + +#include <stddef.h> // size_t + +#include <xsde/cxx/config.hxx> +#include <xsde/cxx/ro-string.hxx> +#include <xsde/cxx/hashmap.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + struct substitution_map: hashmap + { + ~substitution_map (); + + substitution_map (size_t buckets); + + void + insert (const char* root, + const char* member_ns, + const char* member_name, + const char* member_type); + + // Check whether there is a substitution available for this + // root element with the specified type. If so, return true + // and override namespace and name (ns is 0 if there is no + // namespace). + // + bool + check (const char*& ns, + const char*& name, + const char* type) const; + + private: + bool + check_ (const char*& ns, + const char*& name, + const char* type) const; + + private: + struct value + { + const char* ns_; + const char* name_; + }; + }; + + + // Translation unit initializer. + // + struct substitution_map_init + { + static substitution_map* map; + static size_t count; + + substitution_map_init (); + ~substitution_map_init (); + }; + + substitution_map& + substitution_map_instance (); + + // Map entry initializer. + // + struct substitution_map_entry + { + substitution_map_entry (const char* root, + const char* member_ns, + const char* member_name, + const char* member_type); + }; + } + } +} + +#include <xsde/cxx/serializer/substitution-map.ixx> + +#endif // XSDE_CXX_SERIALIZER_SUBSTITUTION_MAP_HXX + diff --git a/libxsde/xsde/cxx/serializer/substitution-map.ixx b/libxsde/xsde/cxx/serializer/substitution-map.ixx new file mode 100644 index 0000000..63a848a --- /dev/null +++ b/libxsde/xsde/cxx/serializer/substitution-map.ixx @@ -0,0 +1,33 @@ +// file : xsde/cxx/serializer/substitution-map.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + inline substitution_map:: + substitution_map (size_t buckets) + : hashmap (buckets, sizeof (hashmap*)) + { + } + + inline bool substitution_map:: + check (const char*& ns, + const char*& name, + const char* type) const + { + return empty () ? false : check_ (ns, name, type); + } + + inline substitution_map& + substitution_map_instance () + { + return *substitution_map_init::map; + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/any-type.hxx b/libxsde/xsde/cxx/serializer/validating/any-type.hxx new file mode 100644 index 0000000..ca80572 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/any-type.hxx @@ -0,0 +1,43 @@ +// file : xsde/cxx/serializer/validating/any-type.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_VALIDATING_ANY_TYPE_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_ANY_TYPE_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + // any_type + // +#ifdef XSDE_REUSE_STYLE_MIXIN + struct any_type_simpl: virtual any_type_sskel +#else + struct any_type_simpl: any_type_sskel +#endif + { + }; + + // any_simple_type + // +#ifdef XSDE_REUSE_STYLE_MIXIN + struct any_simple_type_simpl: virtual any_simple_type_sskel +#else + struct any_simple_type_simpl: any_simple_type_sskel +#endif + { + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_ANY_TYPE_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/base64-binary.cxx b/libxsde/xsde/cxx/serializer/validating/base64-binary.cxx new file mode 100644 index 0000000..a649433 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/base64-binary.cxx @@ -0,0 +1,166 @@ +// file : xsde/cxx/serializer/validating/base64-binary.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/serializer/validating/base64-binary.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + base64_binary_simpl:: + ~base64_binary_simpl () + { + if (free_) + delete const_cast<buffer*> (value_); + } + + void base64_binary_simpl:: + pre (const buffer* value) + { + value_ = value; + } + + static const char base64_tab[] = { + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', + 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', + 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', + 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', + 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', + 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', + '8', '9', '+', '/', '\0' + }; + + inline void + split_1 (char b, unsigned char& b1, unsigned char& b2) + { + unsigned char ub = static_cast<unsigned char> (b); + b1 = ub >> 2; + b2 = (ub & 0x3) << 4; + } + + inline void + split_2 (char b, unsigned char& b2, unsigned char& b3) + { + unsigned char ub = static_cast<unsigned char> (b); + b2 |= ub >> 4; + b3 = (ub & 0x0F) << 2; + } + + inline void + split_3 (char b, unsigned char& b3, unsigned char& b4) + { + unsigned char ub = static_cast<unsigned char> (b); + b3 |= ub >> 6; + b4 = ( ub & 0x3F ); + } + + void base64_binary_simpl:: + _serialize_content () + { + // Maximum 76 characters per line, 76/4 = 19 + // + const size_t quads_per_line = 19; + char buf[quads_per_line * 4 + 1]; + + if (size_t size = value_->size ()) + { + const char* data = value_->data (); + size_t quads = (size + 2) / 3; + + // Process all quadruplets except the last, one line at a time. + // + size_t i = 0; + size_t j = 0; + unsigned char b1, b2, b3, b4; + + for (; j < (quads - 1);) + { + for (; i < quads_per_line && j < (quads - 1); ++i, ++j) + { + split_1 (*data++, b1, b2); + split_2 (*data++, b2, b3); + split_3 (*data++, b3, b4); + + buf[i * 4] = base64_tab[b1]; + buf[i * 4 + 1] = base64_tab[b2]; + buf[i * 4 + 2] = base64_tab[b3]; + buf[i * 4 + 3] = base64_tab[b4]; + } + + if (i == quads_per_line) + { + buf[i * 4] = '\n'; + +#ifdef XSDE_EXCEPTIONS + _characters (buf, i * 4 + 1); +#else + if (!_characters (buf, i * 4 + 1)) + break; +#endif + i = 0; + } + } + +#ifndef XSDE_EXCEPTIONS + if (j == (quads - 1)) + { +#endif + // Process last quadruplet. The first byte is always present. + // + split_1 (*data++, b1, b2); + buf[i * 4] = base64_tab[b1]; + + if (data != value_->end ()) + { + // Second byte is present. + // + split_2 (*data++, b2, b3); + buf[i * 4 + 1] = base64_tab[b2]; + + if(data != value_->end ()) + { + // Third byte is present. + // + split_3 (*data++, b3, b4); + buf[i * 4 + 2] = base64_tab[b3]; + buf[i * 4 + 3] = base64_tab[b4]; + } + else + { + buf[i * 4 + 2] = base64_tab[b3]; + buf[i * 4 + 3] = '='; + } + } + else + { + buf[i * 4 + 1] = base64_tab[b2]; + buf[i * 4 + 2] = '='; + buf[i * 4 + 3] = '='; + } + + i++; + + buf[i * 4] = '\n'; + _characters (buf, i * 4 + 1); + +#ifndef XSDE_EXCEPTIONS + } +#endif + } + + if (free_) + { + delete const_cast<buffer*> (value_); + value_ = 0; + } + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/base64-binary.hxx b/libxsde/xsde/cxx/serializer/validating/base64-binary.hxx new file mode 100644 index 0000000..9b8b050 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/base64-binary.hxx @@ -0,0 +1,47 @@ +// file : xsde/cxx/serializer/validating/base64-binary.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_VALIDATING_BASE64_BINARY_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_BASE64_BINARY_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct base64_binary_simpl: virtual base64_binary_sskel +#else + struct base64_binary_simpl: base64_binary_sskel +#endif + { + virtual + ~base64_binary_simpl (); + + base64_binary_simpl (bool free = false); + + virtual void + pre (const buffer*); + + virtual void + _serialize_content (); + + protected: + bool free_; + const buffer* value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/base64-binary.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_BASE64_BINARY_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/base64-binary.ixx b/libxsde/xsde/cxx/serializer/validating/base64-binary.ixx new file mode 100644 index 0000000..5da3828 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/base64-binary.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/validating/base64-binary.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + inline base64_binary_simpl:: + base64_binary_simpl (bool free) + : free_ (free), value_ (0) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/boolean.cxx b/libxsde/xsde/cxx/serializer/validating/boolean.cxx new file mode 100644 index 0000000..82e8ed5 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/boolean.cxx @@ -0,0 +1,30 @@ +// file : xsde/cxx/serializer/validating/boolean.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/serializer/validating/boolean.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void boolean_simpl:: + pre (bool value) + { + value_ = value; + } + + void boolean_simpl:: + _serialize_content () + { + _characters ((value_ ? "true" : "false"), (value_ ? 4 : 5)); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/boolean.hxx b/libxsde/xsde/cxx/serializer/validating/boolean.hxx new file mode 100644 index 0000000..d6b698a --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/boolean.hxx @@ -0,0 +1,39 @@ +// file : xsde/cxx/serializer/validating/boolean.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_VALIDATING_BOOLEAN_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_BOOLEAN_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct boolean_simpl: virtual boolean_sskel +#else + struct boolean_simpl: boolean_sskel +#endif + { + virtual void + pre (bool); + + virtual void + _serialize_content (); + + protected: + bool value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_BOOLEAN_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/byte.cxx b/libxsde/xsde/cxx/serializer/validating/byte.cxx new file mode 100644 index 0000000..c5e5726 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/byte.cxx @@ -0,0 +1,45 @@ +// file : xsde/cxx/serializer/validating/byte.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/validating/byte.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void byte_simpl:: + pre (signed char value) + { + value_ = value; + } + + void byte_simpl:: + _serialize_content () + { + // We only need strlen("-128") + 1 characters to hold all + // representations of signed byte. + // + char str[5]; + +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 5, "%d", value_); +#else + int n = sprintf (str, "%d", value_); +#endif + if (n > 0 && n < 5) + _characters (str, static_cast<size_t> (n)); + else + _schema_error (schema_error::invalid_byte_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/byte.hxx b/libxsde/xsde/cxx/serializer/validating/byte.hxx new file mode 100644 index 0000000..be7e683 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/byte.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/validating/byte.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_VALIDATING_BYTE_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_BYTE_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + // 8-bit signed integer + // +#ifdef XSDE_REUSE_STYLE_MIXIN + struct byte_simpl: virtual byte_sskel +#else + struct byte_simpl: byte_sskel +#endif + { + virtual void + pre (signed char); + + virtual void + _serialize_content (); + + protected: + signed char value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_BYTE_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/date-time.cxx b/libxsde/xsde/cxx/serializer/validating/date-time.cxx new file mode 100644 index 0000000..cacc6ea --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/date-time.cxx @@ -0,0 +1,87 @@ +// file : xsde/cxx/serializer/validating/date-time.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/validating/date-time.hxx> +#include <xsde/cxx/serializer/validating/time-zone.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void date_time_simpl:: + pre (const date_time& value) + { + value_ = value; + } + + void date_time_simpl:: + _serialize_content () + { + // We only need strlen("-2147483649-MM-DDThh:mm:ss.ssssss-hh:mm") + // + 1 characters to hold all representations of date_time. We + // know that the seconds part (represented as double) has + // default precision of 6. + // + char str[40]; + + int y = value_.year (); + unsigned short m = value_.month (); + unsigned short d = value_.day (); + + unsigned short h = value_.hours (); + unsigned short tm = value_.minutes (); + double s = value_.seconds (); + + if (y != 0 && m > 0 && m < 13 && d > 0 && d < 32 && + ((h < 24 && tm < 60 && s >= 0.0 && s < 60.0) || + (h == 24 && tm == 0 && s == 0.0)) && + (!value_.zone_present () || bits::valid_time_zone (value_))) + { +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 34, "%.4d-%.2u-%.2uT%.2u:%.2u:%09f", + y, m, d, h, tm, s); +#else + int n = sprintf (str, "%.4d-%.2u-%.2uT%.2u:%.2u:%09f", + y, m, d, h, tm, s); +#endif + if (n > 0 && n < 34) + { + // Remove trailing '0' and '.' if necessary. + // + while (str[n - 1] == '0') + n--; + + if (str[n - 1] == '.') + n--; + + if (value_.zone_present ()) + { + if (int z = bits::serialize_time_zone (str + n, value_)) + n += z; + else + { + _schema_error (schema_error::invalid_date_time_value); + return; + } + } + + _characters (str, static_cast<size_t> (n)); + } + else + _schema_error (schema_error::invalid_date_time_value); + } + else + _schema_error (schema_error::invalid_date_time_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/date-time.hxx b/libxsde/xsde/cxx/serializer/validating/date-time.hxx new file mode 100644 index 0000000..0cfcab1 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/date-time.hxx @@ -0,0 +1,43 @@ +// file : xsde/cxx/serializer/validating/date-time.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_VALIDATING_DATE_TIME_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_DATE_TIME_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct date_time_simpl: virtual date_time_sskel +#else + struct date_time_simpl: date_time_sskel +#endif + { + date_time_simpl (); + + virtual void + pre (const date_time&); + + virtual void + _serialize_content (); + + protected: + date_time value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/date-time.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_DATE_TIME_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/date-time.ixx b/libxsde/xsde/cxx/serializer/validating/date-time.ixx new file mode 100644 index 0000000..e5e5813 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/date-time.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/validating/date-time.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + inline date_time_simpl:: + date_time_simpl () + : value_ (1, 0, 0, 0, 0, 0.0) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/date.cxx b/libxsde/xsde/cxx/serializer/validating/date.cxx new file mode 100644 index 0000000..b374c1c --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/date.cxx @@ -0,0 +1,71 @@ +// file : xsde/cxx/serializer/validating/date.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/validating/date.hxx> +#include <xsde/cxx/serializer/validating/time-zone.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void date_simpl:: + pre (const date& value) + { + value_ = value; + } + + void date_simpl:: + _serialize_content () + { + // We only need strlen("-2147483649-MM-DD+hh:mm") + 1 characters to + // hold all representations of date. + // + char str[24]; + + int y = value_.year (); + unsigned short m = value_.month (); + unsigned short d = value_.day (); + + if (y != 0 && m > 0 && m < 13 && d > 0 && d < 32 && + (!value_.zone_present () || bits::valid_time_zone (value_))) + { +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 18, "%.4d-%.2u-%.2u", + value_.year (), value_.month (), value_.day ()); +#else + int n = sprintf (str, "%.4d-%.2u-%.2u", + value_.year (), value_.month (), value_.day ()); +#endif + if (n > 0 && n < 18) + { + if (value_.zone_present ()) + { + if (int z = bits::serialize_time_zone (str + n, value_)) + n += z; + else + { + _schema_error (schema_error::invalid_date_value); + return; + } + } + + _characters (str, static_cast<size_t> (n)); + } + else + _schema_error (schema_error::invalid_date_value); + } + else + _schema_error (schema_error::invalid_date_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/date.hxx b/libxsde/xsde/cxx/serializer/validating/date.hxx new file mode 100644 index 0000000..caaf4a5 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/date.hxx @@ -0,0 +1,43 @@ +// file : xsde/cxx/serializer/validating/date.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_VALIDATING_DATE_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_DATE_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct date_simpl: virtual date_sskel +#else + struct date_simpl: date_sskel +#endif + { + date_simpl (); + + virtual void + pre (const date&); + + virtual void + _serialize_content (); + + protected: + date value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/date.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_DATE_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/date.ixx b/libxsde/xsde/cxx/serializer/validating/date.ixx new file mode 100644 index 0000000..f5c3706 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/date.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/validating/date.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + inline date_simpl:: + date_simpl () + : value_ (1, 1, 1) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/decimal.cxx b/libxsde/xsde/cxx/serializer/validating/decimal.cxx new file mode 100644 index 0000000..7383025 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/decimal.cxx @@ -0,0 +1,66 @@ +// file : xsde/cxx/serializer/validating/decimal.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/validating/decimal.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void decimal_simpl:: + pre (double value) + { + value_ = value; + } + + void decimal_simpl:: + _serialize_content () + { + // Assume double values cannot be longer than 127 characters. + // + char str[128]; + +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 128, "%.*f", + static_cast<int> (precision_), value_); +#else + int n = sprintf (str, "%.*f", + static_cast<int> (precision_), value_); +#endif + if (n > 0 && n < 128) + { + // For decimal, NaN and INF are not allowed. + // + int i = (str[0] == '-' ? 1 : 0); + if ((str[i] == 'i' && str[i + 1] == 'n' && str[i + 2] == 'f') || + (str[i] == 'n' && str[i + 1] == 'a' && str[i + 2] == 'n')) + { + _schema_error (schema_error::invalid_decimal_value); + return; + } + + // Remove trailing '0' and '.' if necessary. + // + while (str[n - 1] == '0') + n--; + + if (str[n - 1] == '.') + n--; + + _characters (str, static_cast<size_t> (n)); + } + else + _schema_error (schema_error::invalid_decimal_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/decimal.hxx b/libxsde/xsde/cxx/serializer/validating/decimal.hxx new file mode 100644 index 0000000..af2c0f1 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/decimal.hxx @@ -0,0 +1,50 @@ +// file : xsde/cxx/serializer/validating/decimal.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_VALIDATING_DECIMAL_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_DECIMAL_HXX + +#include <float.h> + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct decimal_simpl: virtual decimal_sskel +#else + struct decimal_simpl: decimal_sskel +#endif + { +#ifdef DBL_DIG + decimal_simpl (unsigned int precision = DBL_DIG); +#else + decimal_simpl (unsigned int precision = 15) +#endif + + virtual void + pre (double); + + virtual void + _serialize_content (); + + protected: + unsigned int precision_; + double value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/decimal.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_DECIMAL_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/decimal.ixx b/libxsde/xsde/cxx/serializer/validating/decimal.ixx new file mode 100644 index 0000000..803253d --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/decimal.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/validating/decimal.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + inline decimal_simpl:: + decimal_simpl (unsigned int p) + : precision_ (p) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/double.cxx b/libxsde/xsde/cxx/serializer/validating/double.cxx new file mode 100644 index 0000000..526eba0 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/double.cxx @@ -0,0 +1,105 @@ +// file : xsde/cxx/serializer/validating/double.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/validating/double.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void double_simpl:: + pre (double value) + { + value_ = value; + } + + void double_simpl:: + _serialize_content () + { + // Assume double values cannot be longer than 127 characters. + // + char str[128]; + + const char* fmt = 0; + + switch (notation_) + { + case notation_auto: + { + fmt = "%.*g"; + break; + } + case notation_fixed: + { + fmt = "%.*f"; + break; + } + case notation_scientific: + { + fmt = "%.*e"; + break; + } + } + +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 128, fmt, precision_, value_); +#else + int n = sprintf (str, fmt, precision_, value_); +#endif + if (n > 0 && n < 128) + { + if (str[0] == '-') + { + if (str[1] == 'n' && str[2] == 'a' && str[3] == 'n') + { + _characters ("NaN", 3); + return; + } + else if (str[1] == 'i' && str[2] == 'n' && str[3] == 'f') + { + _characters ("-INF", 4); + return; + } + } + else + { + if (str[0] == 'n' && str[1] == 'a' && str[2] == 'n') + { + _characters ("NaN", 3); + return; + } + else if (str[0] == 'i' && str[1] == 'n' && str[2] == 'f') + { + _characters ("INF", 3); + return; + } + } + + if (notation_ == notation_fixed) + { + // Remove trailing '0' and '.' if necessary. + // + while (str[n - 1] == '0') + n--; + + if (str[n - 1] == '.') + n--; + } + + _characters (str, static_cast<size_t> (n)); + } + else + _schema_error (schema_error::invalid_double_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/double.hxx b/libxsde/xsde/cxx/serializer/validating/double.hxx new file mode 100644 index 0000000..e7d1324 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/double.hxx @@ -0,0 +1,60 @@ +// file : xsde/cxx/serializer/validating/double.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_VALIDATING_DOUBLE_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_DOUBLE_HXX + +#include <float.h> + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct double_simpl: virtual double_sskel +#else + struct double_simpl: double_sskel +#endif + { + enum notation + { + notation_auto, + notation_fixed, + notation_scientific + }; + +#ifdef DBL_DIG + double_simpl (notation = notation_auto, + unsigned int precision = DBL_DIG); +#else + double_simpl (notation = notation_auto, + unsigned int precision = 15) +#endif + + virtual void + pre (double); + + virtual void + _serialize_content (); + + protected: + notation notation_; + unsigned int precision_; + double value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/double.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_DOUBLE_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/double.ixx b/libxsde/xsde/cxx/serializer/validating/double.ixx new file mode 100644 index 0000000..8ae69e6 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/double.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/validating/double.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + inline double_simpl:: + double_simpl (notation n, unsigned int p) + : notation_ (n), precision_ (p) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/duration.cxx b/libxsde/xsde/cxx/serializer/validating/duration.cxx new file mode 100644 index 0000000..7187da5 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/duration.cxx @@ -0,0 +1,195 @@ +// file : xsde/cxx/serializer/validating/duration.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/validating/duration.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void duration_simpl:: + pre (const duration& value) + { + value_ = value; + } + + void duration_simpl:: + _serialize_content () + { + if (value_.seconds () < 0.0) + { + _schema_error (schema_error::invalid_duration_value); + return; + } + + // duration := -PnYnMnDTnHnMnS + // + // The years, months, days, hours, and minutes components are + // represented as 32 unsigned integers with maximum string + // representation being strlen ("4294967295") = 10. + // + // We assume that the seconds part (double) cannot be longer + // than 128 chars. + // + // The total representation thus cannot exceed 10*5 + 128 + + // 9 + 1 = 188 characters. + // + char str[188]; + char* p = str; + + if (value_.negative ()) + *p++ = '-'; + + *p++ = 'P'; + + // years + // + // In case it is 0-duration, use the years field to handle + // this case. + // + if (value_.years () != 0 || + (value_.months () == 0 && + value_.days () == 0 && + value_.hours () == 0 && + value_.minutes () == 0 && + value_.seconds () == 0.0)) + { +#ifdef XSDE_SNPRINTF + int n = snprintf (p, 11, "%u", value_.years ()); +#else + int n = sprintf (p, "%u", value_.years ()); +#endif + if (n < 0 || n >= 11) + { + _schema_error (schema_error::invalid_duration_value); + return; + } + + p += n; + *p++ = 'Y'; + } + + // months + // + if (value_.months () != 0) + { +#ifdef XSDE_SNPRINTF + int n = snprintf (p, 11, "%u", value_.months ()); +#else + int n = sprintf (p, "%u", value_.months ()); +#endif + if (n < 0 || n >= 11) + { + _schema_error (schema_error::invalid_duration_value); + return; + } + + p += n; + *p++ = 'M'; + } + + // days + // + if (value_.days () != 0) + { +#ifdef XSDE_SNPRINTF + int n = snprintf (p, 11, "%u", value_.days ()); +#else + int n = sprintf (p, "%u", value_.days ()); +#endif + if (n < 0 || n >= 11) + { + _schema_error (schema_error::invalid_duration_value); + return; + } + + p += n; + *p++ = 'D'; + } + + // Figure out if we need the 'T' delimiter. + // + if (value_.hours () != 0 || + value_.minutes () != 0 || + value_.seconds () != 0.0) + *p++ = 'T'; + + // hours + // + if (value_.hours () != 0) + { +#ifdef XSDE_SNPRINTF + int n = snprintf (p, 11, "%u", value_.hours ()); +#else + int n = sprintf (p, "%u", value_.hours ()); +#endif + if (n < 0 || n >= 11) + { + _schema_error (schema_error::invalid_duration_value); + return; + } + + p += n; + *p++ = 'H'; + } + + // minutes + // + if (value_.minutes () != 0) + { +#ifdef XSDE_SNPRINTF + int n = snprintf (p, 11, "%u", value_.minutes ()); +#else + int n = sprintf (p, "%u", value_.minutes ()); +#endif + if (n < 0 || n >= 11) + { + _schema_error (schema_error::invalid_duration_value); + return; + } + + p += n; + *p++ = 'M'; + } + + // seconds + // + if (value_.seconds () > 0.0) + { +#ifdef XSDE_SNPRINTF + int n = snprintf (p, 128, "%f", value_.seconds ()); +#else + int n = sprintf (p, "%f", value_.seconds ()); +#endif + if (n < 0 || n >= 128) + { + _schema_error (schema_error::invalid_duration_value); + return; + } + + // Remove trailing '0' and '.' if necessary. + // + while (p[n - 1] == '0') + n--; + + if (p[n - 1] == '.') + n--; + + p += n; + *p++ = 'S'; + } + + _characters (str, static_cast<size_t> (p - str)); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/duration.hxx b/libxsde/xsde/cxx/serializer/validating/duration.hxx new file mode 100644 index 0000000..edc5473 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/duration.hxx @@ -0,0 +1,43 @@ +// file : xsde/cxx/serializer/validating/duration.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_VALIDATING_DURATION_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_DURATION_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct duration_simpl: virtual duration_sskel +#else + struct duration_simpl: duration_sskel +#endif + { + duration_simpl (); + + virtual void + pre (const duration&); + + virtual void + _serialize_content (); + + protected: + duration value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/duration.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_DURATION_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/duration.ixx b/libxsde/xsde/cxx/serializer/validating/duration.ixx new file mode 100644 index 0000000..334a288 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/duration.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/validating/duration.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + inline duration_simpl:: + duration_simpl () + : value_ (false, 1, 0, 0, 0, 0, 0.0) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/float.cxx b/libxsde/xsde/cxx/serializer/validating/float.cxx new file mode 100644 index 0000000..d9ee49c --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/float.cxx @@ -0,0 +1,105 @@ +// file : xsde/cxx/serializer/validating/float.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/validating/float.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void float_simpl:: + pre (float value) + { + value_ = value; + } + + void float_simpl:: + _serialize_content () + { + // Assume float values cannot be longer than 127 characters. + // + char str[128]; + + const char* fmt = 0; + + switch (notation_) + { + case notation_auto: + { + fmt = "%.*g"; + break; + } + case notation_fixed: + { + fmt = "%.*f"; + break; + } + case notation_scientific: + { + fmt = "%.*e"; + break; + } + } + +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 128, fmt, precision_, value_); +#else + int n = sprintf (str, fmt, precision_, value_); +#endif + if (n > 0 && n < 128) + { + if (str[0] == '-') + { + if (str[1] == 'n' && str[2] == 'a' && str[3] == 'n') + { + _characters ("NaN", 3); + return; + } + else if (str[1] == 'i' && str[2] == 'n' && str[3] == 'f') + { + _characters ("-INF", 4); + return; + } + } + else + { + if (str[0] == 'n' && str[1] == 'a' && str[2] == 'n') + { + _characters ("NaN", 3); + return; + } + else if (str[0] == 'i' && str[1] == 'n' && str[2] == 'f') + { + _characters ("INF", 3); + return; + } + } + + if (notation_ == notation_fixed) + { + // Remove trailing '0' and '.' if necessary. + // + while (str[n - 1] == '0') + n--; + + if (str[n - 1] == '.') + n--; + } + + _characters (str, static_cast<size_t> (n)); + } + else + _schema_error (schema_error::invalid_float_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/float.hxx b/libxsde/xsde/cxx/serializer/validating/float.hxx new file mode 100644 index 0000000..6a9b9df --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/float.hxx @@ -0,0 +1,60 @@ +// file : xsde/cxx/serializer/validating/float.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_VALIDATING_FLOAT_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_FLOAT_HXX + +#include <float.h> + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct float_simpl: virtual float_sskel +#else + struct float_simpl: float_sskel +#endif + { + enum notation + { + notation_auto, + notation_fixed, + notation_scientific + }; + +#ifdef FLT_DIG + float_simpl (notation = notation_auto, + unsigned int precision = FLT_DIG); +#else + float_simpl (notation = notation_auto, + unsigned int precision = 6) +#endif + + virtual void + pre (float); + + virtual void + _serialize_content (); + + protected: + notation notation_; + unsigned int precision_; + float value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/float.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_FLOAT_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/float.ixx b/libxsde/xsde/cxx/serializer/validating/float.ixx new file mode 100644 index 0000000..b240b6e --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/float.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/validating/float.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + inline float_simpl:: + float_simpl (notation n, unsigned int p) + : notation_ (n), precision_ (p) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/gday.cxx b/libxsde/xsde/cxx/serializer/validating/gday.cxx new file mode 100644 index 0000000..363757b --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/gday.cxx @@ -0,0 +1,67 @@ +// file : xsde/cxx/serializer/validating/gday.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/validating/gday.hxx> +#include <xsde/cxx/serializer/validating/time-zone.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void gday_simpl:: + pre (const gday& value) + { + value_ = value; + } + + void gday_simpl:: + _serialize_content () + { + // We only need strlen("---DD+hh:mm") + 1 characters to hold all + // representations of gDay. + // + char str[12]; + + unsigned short d = value_.day (); + + if (d > 0 && d < 32 && + (!value_.zone_present () || bits::valid_time_zone (value_))) + { +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 6, "---%.2u", d); +#else + int n = sprintf (str, "---%.2u", d); +#endif + if (n > 0 && n < 6) + { + if (value_.zone_present ()) + { + if (int z = bits::serialize_time_zone (str + n, value_)) + n += z; + else + { + _schema_error (schema_error::invalid_gday_value); + return; + } + } + + _characters (str, static_cast<size_t> (n)); + } + else + _schema_error (schema_error::invalid_gday_value); + } + else + _schema_error (schema_error::invalid_gday_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/gday.hxx b/libxsde/xsde/cxx/serializer/validating/gday.hxx new file mode 100644 index 0000000..856229b --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/gday.hxx @@ -0,0 +1,43 @@ +// file : xsde/cxx/serializer/validating/gday.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_VALIDATING_GDAY_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_GDAY_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct gday_simpl: virtual gday_sskel +#else + struct gday_simpl: gday_sskel +#endif + { + gday_simpl (); + + virtual void + pre (const gday&); + + virtual void + _serialize_content (); + + protected: + gday value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/gday.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_GDAY_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/gday.ixx b/libxsde/xsde/cxx/serializer/validating/gday.ixx new file mode 100644 index 0000000..04e6261 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/gday.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/validating/gday.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + inline gday_simpl:: + gday_simpl () + : value_ (1) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/gmonth-day.cxx b/libxsde/xsde/cxx/serializer/validating/gmonth-day.cxx new file mode 100644 index 0000000..fd8f461 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/gmonth-day.cxx @@ -0,0 +1,68 @@ +// file : xsde/cxx/serializer/validating/gmonth-day.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/validating/gmonth-day.hxx> +#include <xsde/cxx/serializer/validating/time-zone.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void gmonth_day_simpl:: + pre (const gmonth_day& value) + { + value_ = value; + } + + void gmonth_day_simpl:: + _serialize_content () + { + // We only need strlen("--MM-DD+hh:mm") + 1 characters to hold all + // representations of gMonthDay. + // + char str[14]; + + unsigned short m = value_.month (); + unsigned short d = value_.day (); + + if (m > 0 && m < 13 && d > 0 && d < 32 && + (!value_.zone_present () || bits::valid_time_zone (value_))) + { +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 8, "--%.2u-%.2u", m, d); +#else + int n = sprintf (str, "--%.2u-%.2u", m, d); +#endif + if (n > 0 && n < 8) + { + if (value_.zone_present ()) + { + if (int z = bits::serialize_time_zone (str + n, value_)) + n += z; + else + { + _schema_error (schema_error::invalid_gmonth_day_value); + return; + } + } + + _characters (str, static_cast<size_t> (n)); + } + else + _schema_error (schema_error::invalid_gmonth_day_value); + } + else + _schema_error (schema_error::invalid_gmonth_day_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/gmonth-day.hxx b/libxsde/xsde/cxx/serializer/validating/gmonth-day.hxx new file mode 100644 index 0000000..60d5d11 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/gmonth-day.hxx @@ -0,0 +1,43 @@ +// file : xsde/cxx/serializer/validating/gmonth-day.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_VALIDATING_GMONTH_DAY_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_GMONTH_DAY_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct gmonth_day_simpl: virtual gmonth_day_sskel +#else + struct gmonth_day_simpl: gmonth_day_sskel +#endif + { + gmonth_day_simpl (); + + virtual void + pre (const gmonth_day&); + + virtual void + _serialize_content (); + + protected: + gmonth_day value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/gmonth-day.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_GMONTH_DAY_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/gmonth-day.ixx b/libxsde/xsde/cxx/serializer/validating/gmonth-day.ixx new file mode 100644 index 0000000..23581ee --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/gmonth-day.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/validating/gmonth-day.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + inline gmonth_day_simpl:: + gmonth_day_simpl () + : value_ (1, 1) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/gmonth.cxx b/libxsde/xsde/cxx/serializer/validating/gmonth.cxx new file mode 100644 index 0000000..ad5cf27 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/gmonth.cxx @@ -0,0 +1,67 @@ +// file : xsde/cxx/serializer/validating/gmonth.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/validating/gmonth.hxx> +#include <xsde/cxx/serializer/validating/time-zone.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void gmonth_simpl:: + pre (const gmonth& value) + { + value_ = value; + } + + void gmonth_simpl:: + _serialize_content () + { + // We only need strlen("--MM+hh:mm") + 1 characters to hold all + // representations of gMonth. + // + char str[11]; + + unsigned short m = value_.month (); + + if (m > 0 && m < 13 && + (!value_.zone_present () || bits::valid_time_zone (value_))) + { +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 5, "--%.2u", m); +#else + int n = sprintf (str, "--%.2u", m); +#endif + if (n > 0 && n < 5) + { + if (value_.zone_present ()) + { + if (int z = bits::serialize_time_zone (str + n, value_)) + n += z; + else + { + _schema_error (schema_error::invalid_gmonth_value); + return; + } + } + + _characters (str, static_cast<size_t> (n)); + } + else + _schema_error (schema_error::invalid_gmonth_value); + } + else + _schema_error (schema_error::invalid_gmonth_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/gmonth.hxx b/libxsde/xsde/cxx/serializer/validating/gmonth.hxx new file mode 100644 index 0000000..10d9575 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/gmonth.hxx @@ -0,0 +1,43 @@ +// file : xsde/cxx/serializer/validating/gmonth.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_VALIDATING_GMONTH_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_GMONTH_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct gmonth_simpl: virtual gmonth_sskel +#else + struct gmonth_simpl: gmonth_sskel +#endif + { + gmonth_simpl (); + + virtual void + pre (const gmonth&); + + virtual void + _serialize_content (); + + protected: + gmonth value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/gmonth.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_GMONTH_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/gmonth.ixx b/libxsde/xsde/cxx/serializer/validating/gmonth.ixx new file mode 100644 index 0000000..ae0a8dc --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/gmonth.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/validating/gmonth.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + inline gmonth_simpl:: + gmonth_simpl () + : value_ (1) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/gyear-month.cxx b/libxsde/xsde/cxx/serializer/validating/gyear-month.cxx new file mode 100644 index 0000000..ab4ab15 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/gyear-month.cxx @@ -0,0 +1,68 @@ +// file : xsde/cxx/serializer/validating/gyear-month.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/validating/gyear-month.hxx> +#include <xsde/cxx/serializer/validating/time-zone.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void gyear_month_simpl:: + pre (const gyear_month& value) + { + value_ = value; + } + + void gyear_month_simpl:: + _serialize_content () + { + // We only need strlen("-2147483649-MM+hh:mm") + 1 characters to + // hold all representations of gYearMonth. + // + char str[21]; + + int y = value_.year (); + unsigned short m = value_.month (); + + if (y != 0 && m > 0 && m < 13 && + (!value_.zone_present () || bits::valid_time_zone (value_))) + { +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 15, "%.4d-%.2u", y, m); +#else + int n = sprintf (str, "%.4d-%.2u", y, m); +#endif + if (n > 0 && n < 15) + { + if (value_.zone_present ()) + { + if (int z = bits::serialize_time_zone (str + n, value_)) + n += z; + else + { + _schema_error (schema_error::invalid_gyear_month_value); + return; + } + } + + _characters (str, static_cast<size_t> (n)); + } + else + _schema_error (schema_error::invalid_gyear_month_value); + } + else + _schema_error (schema_error::invalid_gyear_month_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/gyear-month.hxx b/libxsde/xsde/cxx/serializer/validating/gyear-month.hxx new file mode 100644 index 0000000..9a0107e --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/gyear-month.hxx @@ -0,0 +1,43 @@ +// file : xsde/cxx/serializer/validating/gyear-month.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_VALIDATING_GYEAR_MONTH_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_GYEAR_MONTH_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct gyear_month_simpl: virtual gyear_month_sskel +#else + struct gyear_month_simpl: gyear_month_sskel +#endif + { + gyear_month_simpl (); + + virtual void + pre (const gyear_month&); + + virtual void + _serialize_content (); + + protected: + gyear_month value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/gyear-month.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_GYEAR_MONTH_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/gyear-month.ixx b/libxsde/xsde/cxx/serializer/validating/gyear-month.ixx new file mode 100644 index 0000000..5aea7eb --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/gyear-month.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/validating/gyear-month.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + inline gyear_month_simpl:: + gyear_month_simpl () + : value_ (1, 1) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/gyear.cxx b/libxsde/xsde/cxx/serializer/validating/gyear.cxx new file mode 100644 index 0000000..6b34506 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/gyear.cxx @@ -0,0 +1,67 @@ +// file : xsde/cxx/serializer/validating/gyear.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/validating/gyear.hxx> +#include <xsde/cxx/serializer/validating/time-zone.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void gyear_simpl:: + pre (const gyear& value) + { + value_ = value; + } + + void gyear_simpl:: + _serialize_content () + { + // We only need strlen("-2147483649+hh:mm") + 1 characters to + // hold all representations of gYear. + // + char str[18]; + + int y = value_.year (); + + if (y != 0 && + (!value_.zone_present () || bits::valid_time_zone (value_))) + { +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 12, "%.4d", y); +#else + int n = sprintf (str, "%.4d", y); +#endif + if (n > 0 && n < 12) + { + if (value_.zone_present ()) + { + if (int z = bits::serialize_time_zone (str + n, value_)) + n += z; + else + { + _schema_error (schema_error::invalid_gyear_value); + return; + } + } + + _characters (str, static_cast<size_t> (n)); + } + else + _schema_error (schema_error::invalid_gyear_value); + } + else + _schema_error (schema_error::invalid_gyear_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/gyear.hxx b/libxsde/xsde/cxx/serializer/validating/gyear.hxx new file mode 100644 index 0000000..0ae7e1a --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/gyear.hxx @@ -0,0 +1,43 @@ +// file : xsde/cxx/serializer/validating/gyear.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_VALIDATING_GYEAR_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_GYEAR_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct gyear_simpl: virtual gyear_sskel +#else + struct gyear_simpl: gyear_sskel +#endif + { + gyear_simpl (); + + virtual void + pre (const gyear&); + + virtual void + _serialize_content (); + + protected: + gyear value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/gyear.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_GYEAR_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/gyear.ixx b/libxsde/xsde/cxx/serializer/validating/gyear.ixx new file mode 100644 index 0000000..7502a6b --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/gyear.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/validating/gyear.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + inline gyear_simpl:: + gyear_simpl () + : value_ (1) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/hex-binary.cxx b/libxsde/xsde/cxx/serializer/validating/hex-binary.cxx new file mode 100644 index 0000000..0250e71 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/hex-binary.cxx @@ -0,0 +1,70 @@ +// file : xsde/cxx/serializer/validating/hex-binary.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/serializer/validating/hex-binary.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + hex_binary_simpl:: + ~hex_binary_simpl () + { + if (free_) + delete const_cast<buffer*> (value_); + } + + void hex_binary_simpl:: + pre (const buffer* value) + { + value_ = value; + } + + static const char hex_tab[] = "0123456789ABCDEF"; + + void hex_binary_simpl:: + _serialize_content () + { + char buf[512]; + + size_t size = value_->size (); + const char* data = value_->data (); + + // Covert the data in 256-byte chunks. + // + for (size_t j = 0; j < size;) + { + size_t i = 0; + + for (; i < 512 && j < size; ++j) + { + unsigned char byte = static_cast<unsigned char> (data[j]); + + buf[i++] = hex_tab[byte >> 4]; + buf[i++] = hex_tab[byte & 0x0F]; + } + +#ifdef XSDE_EXCEPTIONS + _characters (buf, i); +#else + if (!_characters (buf, i)) + break; +#endif + } + + if (free_) + { + delete const_cast<buffer*> (value_); + value_ = 0; + } + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/hex-binary.hxx b/libxsde/xsde/cxx/serializer/validating/hex-binary.hxx new file mode 100644 index 0000000..524d9a9 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/hex-binary.hxx @@ -0,0 +1,47 @@ +// file : xsde/cxx/serializer/validating/hex-binary.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_VALIDATING_HEX_BINARY_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_HEX_BINARY_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct hex_binary_simpl: virtual hex_binary_sskel +#else + struct hex_binary_simpl: hex_binary_sskel +#endif + { + virtual + ~hex_binary_simpl (); + + hex_binary_simpl (bool free = false); + + virtual void + pre (const buffer*); + + virtual void + _serialize_content (); + + protected: + bool free_; + const buffer* value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/hex-binary.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_HEX_BINARY_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/hex-binary.ixx b/libxsde/xsde/cxx/serializer/validating/hex-binary.ixx new file mode 100644 index 0000000..134d30a --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/hex-binary.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/validating/hex-binary.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + inline hex_binary_simpl:: + hex_binary_simpl (bool free) + : free_ (free), value_ (0) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/id-stl.cxx b/libxsde/xsde/cxx/serializer/validating/id-stl.cxx new file mode 100644 index 0000000..0166069 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/id-stl.cxx @@ -0,0 +1,38 @@ +// file : xsde/cxx/serializer/validating/id-stl.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/xml/ncname.hxx> + +#include <xsde/cxx/serializer/validating/id-stl.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void id_simpl:: + pre (const std::string& value) + { + value_ = value; + } + + void id_simpl:: + _serialize_content () + { + std::string tmp; + tmp.swap (value_); + + if (xml::valid_ncname (tmp.c_str (), tmp.size ())) + _characters (tmp.c_str (), tmp.size ()); + else + _schema_error (schema_error::invalid_id_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/id-stl.hxx b/libxsde/xsde/cxx/serializer/validating/id-stl.hxx new file mode 100644 index 0000000..f804eac --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/id-stl.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/validating/id-stl.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_VALIDATING_ID_STL_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_ID_STL_HXX + +#include <string> + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct id_simpl: virtual id_sskel +#else + struct id_simpl: id_sskel +#endif + { + virtual void + pre (const std::string&); + + virtual void + _serialize_content (); + + protected: + std::string value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_ID_STL_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/id.cxx b/libxsde/xsde/cxx/serializer/validating/id.cxx new file mode 100644 index 0000000..2926ffe --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/id.cxx @@ -0,0 +1,52 @@ +// file : xsde/cxx/serializer/validating/id.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <string.h> // strlen + +#include <xsde/cxx/xml/ncname.hxx> + +#include <xsde/cxx/serializer/validating/id.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + id_simpl:: + ~id_simpl () + { + if (free_) + delete[] const_cast<char*> (value_); + } + + void id_simpl:: + pre (const char* value) + { + value_ = value; + } + + void id_simpl:: + _serialize_content () + { + size_t n = strlen (value_); + + if (xml::valid_ncname (value_, n)) + _characters (value_, n); + else + _schema_error (schema_error::invalid_id_value); + + if (free_) + { + delete[] const_cast<char*> (value_); + value_ = 0; + } + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/id.hxx b/libxsde/xsde/cxx/serializer/validating/id.hxx new file mode 100644 index 0000000..dac47f3 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/id.hxx @@ -0,0 +1,47 @@ +// file : xsde/cxx/serializer/validating/id.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_VALIDATING_ID_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_ID_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct id_simpl: virtual id_sskel +#else + struct id_simpl: id_sskel +#endif + { + virtual + ~id_simpl (); + + id_simpl (bool free = false); + + virtual void + pre (const char*); + + virtual void + _serialize_content (); + + protected: + bool free_; + const char* value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/id.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_ID_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/id.ixx b/libxsde/xsde/cxx/serializer/validating/id.ixx new file mode 100644 index 0000000..d771919 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/id.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/validating/id.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + inline id_simpl:: + id_simpl (bool free) + : free_ (free) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/idref-stl.cxx b/libxsde/xsde/cxx/serializer/validating/idref-stl.cxx new file mode 100644 index 0000000..620b16f --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/idref-stl.cxx @@ -0,0 +1,38 @@ +// file : xsde/cxx/serializer/validating/idref-stl.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/xml/ncname.hxx> + +#include <xsde/cxx/serializer/validating/idref-stl.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void idref_simpl:: + pre (const std::string& value) + { + value_ = value; + } + + void idref_simpl:: + _serialize_content () + { + std::string tmp; + tmp.swap (value_); + + if (xml::valid_ncname (tmp.c_str (), tmp.size ())) + _characters (tmp.c_str (), tmp.size ()); + else + _schema_error (schema_error::invalid_idref_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/idref-stl.hxx b/libxsde/xsde/cxx/serializer/validating/idref-stl.hxx new file mode 100644 index 0000000..e90443e --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/idref-stl.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/validating/idref-stl.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_VALIDATING_IDREF_STL_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_IDREF_STL_HXX + +#include <string> + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct idref_simpl: virtual idref_sskel +#else + struct idref_simpl: idref_sskel +#endif + { + virtual void + pre (const std::string&); + + virtual void + _serialize_content (); + + protected: + std::string value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_IDREF_STL_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/idref.cxx b/libxsde/xsde/cxx/serializer/validating/idref.cxx new file mode 100644 index 0000000..87d6c5c --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/idref.cxx @@ -0,0 +1,52 @@ +// file : xsde/cxx/serializer/validating/idref.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <string.h> // strlen + +#include <xsde/cxx/xml/ncname.hxx> + +#include <xsde/cxx/serializer/validating/idref.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + idref_simpl:: + ~idref_simpl () + { + if (free_) + delete[] const_cast<char*> (value_); + } + + void idref_simpl:: + pre (const char* value) + { + value_ = value; + } + + void idref_simpl:: + _serialize_content () + { + size_t n = strlen (value_); + + if (xml::valid_ncname (value_, n)) + _characters (value_, n); + else + _schema_error (schema_error::invalid_idref_value); + + if (free_) + { + delete[] const_cast<char*> (value_); + value_ = 0; + } + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/idref.hxx b/libxsde/xsde/cxx/serializer/validating/idref.hxx new file mode 100644 index 0000000..b8d82ce --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/idref.hxx @@ -0,0 +1,47 @@ +// file : xsde/cxx/serializer/validating/idref.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_VALIDATING_IDREF_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_IDREF_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct idref_simpl: virtual idref_sskel +#else + struct idref_simpl: idref_sskel +#endif + { + virtual + ~idref_simpl (); + + idref_simpl (bool free = false); + + virtual void + pre (const char*); + + virtual void + _serialize_content (); + + protected: + bool free_; + const char* value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/idref.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_IDREF_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/idref.ixx b/libxsde/xsde/cxx/serializer/validating/idref.ixx new file mode 100644 index 0000000..34a6838 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/idref.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/validating/idref.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + inline idref_simpl:: + idref_simpl (bool free) + : free_ (free) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/idrefs-stl.cxx b/libxsde/xsde/cxx/serializer/validating/idrefs-stl.cxx new file mode 100644 index 0000000..bdcf937 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/idrefs-stl.cxx @@ -0,0 +1,109 @@ +// file : xsde/cxx/serializer/validating/idrefs-stl.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/serializer/validating/idrefs-stl.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + idrefs_simpl:: + ~idrefs_simpl () + { + if (free_) + delete const_cast<string_sequence*> (value_); + } + + void idrefs_simpl:: + pre (const string_sequence* value) + { + value_ = value; + } + + void idrefs_simpl:: + _serialize_content () + { + // Should have at least one element. + // + if (!value_->empty ()) + { + bool first = true; + context& ctx = _context (); + + for (string_sequence::const_iterator i (value_->begin ()), + e (value_->end ()); i != e; ++i) + { + serializer_.pre (*i); + +#ifndef XSDE_EXCEPTIONS + if (serializer_._error_type ()) + serializer_._copy_error (ctx); + + if (ctx.error_type ()) + break; +#endif + + if (!first) + { +#ifdef XSDE_EXCEPTIONS + _characters (" ", 1); +#else + if (!_characters (" ", 1)) + break; +#endif + } + else + first = false; + + serializer_._pre_impl (ctx); + + if (ctx.error_type ()) + break; + + serializer_._serialize_content (); + + if (ctx.error_type ()) + break; + + serializer_._post_impl (); + + if (ctx.error_type ()) + break; + + serializer_.post (); + +#ifndef XSDE_EXCEPTIONS + if (serializer_._error_type ()) + serializer_._copy_error (ctx); + + if (ctx.error_type ()) + break; +#endif + } + } + else + _schema_error (schema_error::invalid_idrefs_value); + + if (free_) + { + delete const_cast<string_sequence*> (value_); + value_ = 0; + } + } + + void idrefs_simpl:: + _reset () + { + idrefs_sskel::_reset (); + serializer_._reset (); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/idrefs-stl.hxx b/libxsde/xsde/cxx/serializer/validating/idrefs-stl.hxx new file mode 100644 index 0000000..03cd1da --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/idrefs-stl.hxx @@ -0,0 +1,52 @@ +// file : xsde/cxx/serializer/validating/idrefs-stl.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_VALIDATING_IDREFS_STL_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_IDREFS_STL_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> +#include <xsde/cxx/serializer/validating/idref-stl.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct idrefs_simpl: virtual idrefs_sskel +#else + struct idrefs_simpl: idrefs_sskel +#endif + { + virtual + ~idrefs_simpl (); + + idrefs_simpl (bool free = false); + + virtual void + pre (const string_sequence*); + + virtual void + _serialize_content (); + + virtual void + _reset (); + + protected: + bool free_; + const string_sequence* value_; + idref_simpl serializer_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/idrefs-stl.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_IDREFS_STL_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/idrefs-stl.ixx b/libxsde/xsde/cxx/serializer/validating/idrefs-stl.ixx new file mode 100644 index 0000000..9c6e46c --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/idrefs-stl.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/validating/idrefs-stl.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + inline idrefs_simpl:: + idrefs_simpl (bool free) + : free_ (free), value_ (0) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/idrefs.cxx b/libxsde/xsde/cxx/serializer/validating/idrefs.cxx new file mode 100644 index 0000000..e6548c4 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/idrefs.cxx @@ -0,0 +1,110 @@ +// file : xsde/cxx/serializer/validating/idrefs.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/serializer/validating/idrefs.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + idrefs_simpl:: + ~idrefs_simpl () + { + if (free_) + delete const_cast<string_sequence*> (value_); + } + + void idrefs_simpl:: + pre (const string_sequence* value) + { + value_ = value; + } + + void idrefs_simpl:: + _serialize_content () + { + // Should have at least one element. + // + if (!value_->empty ()) + { + bool first = true; + context& ctx = _context (); + + for (string_sequence::const_iterator i (value_->begin ()), + e (value_->end ()); i != e; ++i) + { + serializer_.pre (*i); + +#ifndef XSDE_EXCEPTIONS + if (serializer_._error_type ()) + serializer_._copy_error (ctx); + + if (ctx.error_type ()) + break; +#endif + + if (!first) + { +#ifdef XSDE_EXCEPTIONS + _characters (" ", 1); +#else + if (!_characters (" ", 1)) + break; +#endif + } + else + first = false; + + serializer_._pre_impl (ctx); + + if (ctx.error_type ()) + break; + + serializer_._serialize_content (); + + if (ctx.error_type ()) + break; + + serializer_._post_impl (); + + if (ctx.error_type ()) + break; + + serializer_.post (); + +#ifndef XSDE_EXCEPTIONS + if (serializer_._error_type ()) + serializer_._copy_error (ctx); + + if (ctx.error_type ()) + break; +#endif + } + } + else + _schema_error (schema_error::invalid_idrefs_value); + + if (free_) + { + delete const_cast<string_sequence*> (value_); + value_ = 0; + } + } + + void idrefs_simpl:: + _reset () + { + idrefs_sskel::_reset (); + serializer_._reset (); + } + } + } + } +} + diff --git a/libxsde/xsde/cxx/serializer/validating/idrefs.hxx b/libxsde/xsde/cxx/serializer/validating/idrefs.hxx new file mode 100644 index 0000000..23386dd --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/idrefs.hxx @@ -0,0 +1,52 @@ +// file : xsde/cxx/serializer/validating/idrefs.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_VALIDATING_IDREFS_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_IDREFS_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> +#include <xsde/cxx/serializer/validating/idref.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct idrefs_simpl: virtual idrefs_sskel +#else + struct idrefs_simpl: idrefs_sskel +#endif + { + virtual + ~idrefs_simpl (); + + idrefs_simpl (bool free = false); + + virtual void + pre (const string_sequence*); + + virtual void + _serialize_content (); + + virtual void + _reset (); + + protected: + bool free_; + const string_sequence* value_; + idref_simpl serializer_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/idrefs.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_IDREFS_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/idrefs.ixx b/libxsde/xsde/cxx/serializer/validating/idrefs.ixx new file mode 100644 index 0000000..b077e58 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/idrefs.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/validating/idrefs.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + inline idrefs_simpl:: + idrefs_simpl (bool free) + : free_ (free), value_ (0), serializer_ (false) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/inheritance-map-load.hxx b/libxsde/xsde/cxx/serializer/validating/inheritance-map-load.hxx new file mode 100644 index 0000000..abdcd43 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/inheritance-map-load.hxx @@ -0,0 +1,35 @@ +// file : xsde/cxx/serializer/validating/inheritance-map-load.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_VALIDATING_INHERITANCE_MAP_LOAD_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_INHERITANCE_MAP_LOAD_HXX + +#include <stddef.h> // size_t + +#include <xsde/cxx/config.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + size_t + serializer_imap_elements (); + + inline size_t + serializer_imap_buckets () + { + return XSDE_SERIALIZER_IMAP_BUCKETS; + } + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_INHERITANCE_MAP_LOAD_HXX + diff --git a/libxsde/xsde/cxx/serializer/validating/inheritance-map.cxx b/libxsde/xsde/cxx/serializer/validating/inheritance-map.cxx new file mode 100644 index 0000000..94fdabc --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/inheritance-map.cxx @@ -0,0 +1,111 @@ +// file : xsde/cxx/serializer/validating/inheritance-map.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/config.hxx> + +#include <string.h> // strcmp + +#ifndef XSDE_EXCEPTIONS +# include <assert.h> // assert +# include <stdlib.h> // exit +#endif + +#include <xsde/cxx/serializer/validating/inheritance-map.hxx> +#include <xsde/cxx/serializer/validating/inheritance-map-load.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + inheritance_map* inheritance_map_init::map = 0; + size_t inheritance_map_init::count = 0; + + bool inheritance_map:: + check (const char* derived, const char* base) const + { + if (strcmp (derived, base) == 0) + return true; + + const void* p = find (derived); + + if (p) + { + const char* b = *static_cast<const char* const*> (p); + return strcmp (base, b) == 0 ? true : check (b, base); + } + + return false; + } + + // inheritance_map_init + // + inheritance_map_init:: + inheritance_map_init () + { + if (count == 0) + { + map = new inheritance_map (XSDE_SERIALIZER_IMAP_BUCKETS); + +#ifndef XSDE_EXCEPTIONS + if (map == 0 || map->_error () != inheritance_map::error_none) + { + // This is static initialization so there is nothing we can do. + // The best thing is to fail fast. abort() would have probably + // been the better choice here but it is not available on some + // platforms (notably, WinCE). + // + assert (false); + exit (1); + } +#endif + } + + ++count; + } + + inheritance_map_init:: + ~inheritance_map_init () + { + if (--count == 0) + delete map; + } + + // inheritance_map_entry + // + inheritance_map_entry:: + inheritance_map_entry (const char* derived, const char* base) + { + inheritance_map& m = inheritance_map_instance (); + m.insert (derived, base); + +#ifndef XSDE_EXCEPTIONS + if (m._error () != inheritance_map::error_none) + { + // This is static initialization so there is nothing we can do. + // The best thing is to fail fast. abort() would have probably + // been the better choice here but it is not available on some + // platforms (notably, WinCE). + // + assert (false); + exit (1); + } +#endif + } + + // + // + size_t + serializer_imap_elements () + { + return inheritance_map_instance ().size (); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/inheritance-map.hxx b/libxsde/xsde/cxx/serializer/validating/inheritance-map.hxx new file mode 100644 index 0000000..051dbfc --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/inheritance-map.hxx @@ -0,0 +1,63 @@ +// file : xsde/cxx/serializer/validating/inheritance-map.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_VALIDATING_INHERITANCE_MAP_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_INHERITANCE_MAP_HXX + +#include <stddef.h> // size_t + +#include <xsde/cxx/config.hxx> +#include <xsde/cxx/ro-string.hxx> +#include <xsde/cxx/hashmap.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + struct inheritance_map: hashmap + { + inheritance_map (size_t buckets); + + void + insert (const char* derived, const char* base); + + bool + check (const char* derived, const char* base) const; + }; + + + // Translation unit initializer. + // + struct inheritance_map_init + { + static inheritance_map* map; + static size_t count; + + inheritance_map_init (); + ~inheritance_map_init (); + }; + + inline inheritance_map& + inheritance_map_instance (); + + // Map entry initializer. + // + struct inheritance_map_entry + { + inheritance_map_entry (const char* derived, const char* base); + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/inheritance-map.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_INHERITANCE_MAP_HXX + diff --git a/libxsde/xsde/cxx/serializer/validating/inheritance-map.ixx b/libxsde/xsde/cxx/serializer/validating/inheritance-map.ixx new file mode 100644 index 0000000..2ae6fcf --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/inheritance-map.ixx @@ -0,0 +1,34 @@ +// file : xsde/cxx/serializer/validating/inheritance-map.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + inline inheritance_map:: + inheritance_map (size_t buckets) + : hashmap (buckets, sizeof (const char*)) + { + } + + inline void inheritance_map:: + insert (const char* derived, const char* base) + { + hashmap::insert (derived, &base); + } + + inline inheritance_map& + inheritance_map_instance () + { + return *inheritance_map_init::map; + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/int.cxx b/libxsde/xsde/cxx/serializer/validating/int.cxx new file mode 100644 index 0000000..780abbe --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/int.cxx @@ -0,0 +1,45 @@ +// file : xsde/cxx/serializer/validating/int.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/validating/int.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void int_simpl:: + pre (int value) + { + value_ = value; + } + + void int_simpl:: + _serialize_content () + { + // We only need strlen("-2147483649") + 1 characters to hold all + // representations of int. + // + char str[12]; + +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 12, "%d", value_); +#else + int n = sprintf (str, "%d", value_); +#endif + if (n > 0 && n < 12) + _characters (str, static_cast<size_t> (n)); + else + _schema_error (schema_error::invalid_int_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/int.hxx b/libxsde/xsde/cxx/serializer/validating/int.hxx new file mode 100644 index 0000000..6d798d6 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/int.hxx @@ -0,0 +1,39 @@ +// file : xsde/cxx/serializer/validating/int.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_VALIDATING_INT_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_INT_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct int_simpl: virtual int_sskel +#else + struct int_simpl: int_sskel +#endif + { + virtual void + pre (int); + + virtual void + _serialize_content (); + + protected: + int value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_INT_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/integer.cxx b/libxsde/xsde/cxx/serializer/validating/integer.cxx new file mode 100644 index 0000000..8df6c55 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/integer.cxx @@ -0,0 +1,45 @@ +// file : xsde/cxx/serializer/validating/integer.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/validating/integer.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void integer_simpl:: + pre (long value) + { + value_ = value; + } + + void integer_simpl:: + _serialize_content () + { + // We only need strlen("-9223372036854775808") + 1 characters to + // hold all representations of (possibly 64-bit) long. + // + char str[21]; + +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 21, "%ld", value_); +#else + int n = sprintf (str, "%ld", value_); +#endif + if (n > 0 && n < 21) + _characters (str, static_cast<size_t> (n)); + else + _schema_error (schema_error::invalid_integer_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/integer.hxx b/libxsde/xsde/cxx/serializer/validating/integer.hxx new file mode 100644 index 0000000..ada9796 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/integer.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/validating/integer.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_VALIDATING_INTEGER_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_INTEGER_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + // Arbitrary-length integer. Mapped to long. + // +#ifdef XSDE_REUSE_STYLE_MIXIN + struct integer_simpl: virtual integer_sskel +#else + struct integer_simpl: integer_sskel +#endif + { + virtual void + pre (long); + + virtual void + _serialize_content (); + + protected: + long value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_INTEGER_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/language-stl.cxx b/libxsde/xsde/cxx/serializer/validating/language-stl.cxx new file mode 100644 index 0000000..cd4e1d2 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/language-stl.cxx @@ -0,0 +1,73 @@ +// file : xsde/cxx/serializer/validating/language-stl.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/serializer/validating/language-stl.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void language_simpl:: + pre (const std::string& value) + { + value_ = value; + } + + void language_simpl:: + _serialize_content () + { + // Make sure we don't hold any references to the string. + // + std::string tmp; + tmp.swap (value_); + + bool ok = true; + const char* s = tmp.c_str (); + + // language := ALPHA{1,8} *(-(ALPHA | DIGIT){1,8}) + // + for (size_t tag = 0; ; ++tag) + { + size_t n = 0; + + for (; *s != '\0' && n < 8; ++n, ++s) + { + char c = *s; + + if (!((c >= 'a' && c <= 'z') || + (c >= 'A' && c <= 'Z') || + (tag != 0 && c >= '0' && c <= '9'))) + break; + } + + if (n == 0) + { + ok = false; + break; + } + + if (*s == '\0') + break; + + if (*s++ != '-') + { + ok = false; + break; + } + } + + if (ok) + _characters (tmp.c_str (), tmp.size ()); + else + _schema_error (schema_error::invalid_language_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/language-stl.hxx b/libxsde/xsde/cxx/serializer/validating/language-stl.hxx new file mode 100644 index 0000000..2216bff --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/language-stl.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/validating/language-stl.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_VALIDATING_LANGUAGE_STL_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_LANGUAGE_STL_HXX + +#include <string> + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct language_simpl: virtual language_sskel +#else + struct language_simpl: language_sskel +#endif + { + virtual void + pre (const std::string&); + + virtual void + _serialize_content (); + + protected: + std::string value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_LANGUAGE_STL_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/language.cxx b/libxsde/xsde/cxx/serializer/validating/language.cxx new file mode 100644 index 0000000..14f69fc --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/language.cxx @@ -0,0 +1,81 @@ +// file : xsde/cxx/serializer/validating/language.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/serializer/validating/language.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + language_simpl:: + ~language_simpl () + { + if (free_) + delete[] const_cast<char*> (value_); + } + + void language_simpl:: + pre (const char* value) + { + value_ = value; + } + + void language_simpl:: + _serialize_content () + { + bool ok = true; + const char* s = value_; + + // language := ALPHA{1,8} *(-(ALPHA | DIGIT){1,8}) + // + for (size_t tag = 0; ; ++tag) + { + size_t n = 0; + + for (; *s != '\0' && n < 8; ++n, ++s) + { + char c = *s; + + if (!((c >= 'a' && c <= 'z') || + (c >= 'A' && c <= 'Z') || + (tag != 0 && c >= '0' && c <= '9'))) + break; + } + + if (n == 0) + { + ok = false; + break; + } + + if (*s == '\0') + break; + + if (*s++ != '-') + { + ok = false; + break; + } + } + + if (ok) + _characters (value_); + else + _schema_error (schema_error::invalid_language_value); + + if (free_) + { + delete[] const_cast<char*> (value_); + value_ = 0; + } + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/language.hxx b/libxsde/xsde/cxx/serializer/validating/language.hxx new file mode 100644 index 0000000..708a5b0 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/language.hxx @@ -0,0 +1,47 @@ +// file : xsde/cxx/serializer/validating/language.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_VALIDATING_LANGUAGE_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_LANGUAGE_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct language_simpl: virtual language_sskel +#else + struct language_simpl: language_sskel +#endif + { + virtual + ~language_simpl (); + + language_simpl (bool free = false); + + virtual void + pre (const char*); + + virtual void + _serialize_content (); + + protected: + bool free_; + const char* value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/language.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_LANGUAGE_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/language.ixx b/libxsde/xsde/cxx/serializer/validating/language.ixx new file mode 100644 index 0000000..3385220 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/language.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/validating/language.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + inline language_simpl:: + language_simpl (bool free) + : free_ (free) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/long-long.cxx b/libxsde/xsde/cxx/serializer/validating/long-long.cxx new file mode 100644 index 0000000..2773ec7 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/long-long.cxx @@ -0,0 +1,45 @@ +// file : xsde/cxx/serializer/validating/long-long.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/validating/long-long.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void long_simpl:: + pre (long long value) + { + value_ = value; + } + + void long_simpl:: + _serialize_content () + { + // We only need strlen("-9223372036854775808") + 1 characters to + // hold all representations of long long. + // + char str[21]; + +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 21, "%lld", value_); +#else + int n = sprintf (str, "%lld", value_); +#endif + if (n > 0 && n < 21) + _characters (str, static_cast<size_t> (n)); + else + _schema_error (schema_error::invalid_long_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/long-long.hxx b/libxsde/xsde/cxx/serializer/validating/long-long.hxx new file mode 100644 index 0000000..97e14d1 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/long-long.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/validating/long-long.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_VALIDATING_LONG_LONG_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_LONG_LONG_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + // 64-bit signed integer + // +#ifdef XSDE_REUSE_STYLE_MIXIN + struct long_simpl: virtual long_sskel +#else + struct long_simpl: long_sskel +#endif + { + virtual void + pre (long long); + + virtual void + _serialize_content (); + + protected: + long long value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_LONG_LONG_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/long.cxx b/libxsde/xsde/cxx/serializer/validating/long.cxx new file mode 100644 index 0000000..574a22e --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/long.cxx @@ -0,0 +1,45 @@ +// file : xsde/cxx/serializer/validating/long.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/validating/long.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void long_simpl:: + pre (long value) + { + value_ = value; + } + + void long_simpl:: + _serialize_content () + { + // We only need strlen("-9223372036854775808") + 1 characters to + // hold all representations of (possibly 64-bit) long. + // + char str[21]; + +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 21, "%ld", value_); +#else + int n = sprintf (str, "%ld", value_); +#endif + if (n > 0 && n < 21) + _characters (str, static_cast<size_t> (n)); + else + _schema_error (schema_error::invalid_long_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/long.hxx b/libxsde/xsde/cxx/serializer/validating/long.hxx new file mode 100644 index 0000000..7ffadc7 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/long.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/validating/long.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_VALIDATING_LONG_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_LONG_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + // Fall-back implementation when 64 bit long long is not available. + // +#ifdef XSDE_REUSE_STYLE_MIXIN + struct long_simpl: virtual long_sskel +#else + struct long_simpl: long_sskel +#endif + { + virtual void + pre (long); + + virtual void + _serialize_content (); + + protected: + long value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_LONG_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/name-stl.cxx b/libxsde/xsde/cxx/serializer/validating/name-stl.cxx new file mode 100644 index 0000000..e80bf9b --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/name-stl.cxx @@ -0,0 +1,62 @@ +// file : xsde/cxx/serializer/validating/name-stl.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/xml/char-table.hxx> + +#include <xsde/cxx/serializer/validating/name-stl.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void name_simpl:: + pre (const std::string& value) + { + value_ = value; + } + + void name_simpl:: + _serialize_content () + { + // Make sure we don't hold any references to the string. + // + std::string tmp; + tmp.swap (value_); + + const char* s = tmp.c_str (); + bool ok = (*s != '\0'); + + // For now we are only checking the US-ASCII characters. + // + if (ok) + { + // First character. + // + unsigned char c = static_cast<unsigned char> (*s); + + ok = c >= 0x80 || (xml::char_table[c] & xml::name_first_char_mask); + + for (++s; ok && *s != '\0'; ++s) + { + c = static_cast<unsigned char> (*s); + + if (c < 0x80 && !(xml::char_table[c] & xml::name_char_mask)) + ok = false; + } + } + + if (ok) + _characters (tmp.c_str (), tmp.size ()); + else + _schema_error (schema_error::invalid_name_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/name-stl.hxx b/libxsde/xsde/cxx/serializer/validating/name-stl.hxx new file mode 100644 index 0000000..8e67a28 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/name-stl.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/validating/name-stl.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_VALIDATING_NAME_STL_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_NAME_STL_HXX + +#include <string> + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct name_simpl: virtual name_sskel +#else + struct name_simpl: name_sskel +#endif + { + virtual void + pre (const std::string&); + + virtual void + _serialize_content (); + + protected: + std::string value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_NAME_STL_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/name.cxx b/libxsde/xsde/cxx/serializer/validating/name.cxx new file mode 100644 index 0000000..7c916d8 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/name.cxx @@ -0,0 +1,70 @@ +// file : xsde/cxx/serializer/validating/name.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/xml/char-table.hxx> + +#include <xsde/cxx/serializer/validating/name.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + name_simpl:: + ~name_simpl () + { + if (free_) + delete[] const_cast<char*> (value_); + } + + void name_simpl:: + pre (const char* value) + { + value_ = value; + } + + void name_simpl:: + _serialize_content () + { + const char* s = value_; + bool ok = (*s != '\0'); + + // For now we are only checking the US-ASCII characters. + // + if (ok) + { + // First character. + // + unsigned char c = static_cast<unsigned char> (*s); + + ok = c >= 0x80 || (xml::char_table[c] & xml::name_first_char_mask); + + for (++s; ok && *s != '\0'; ++s) + { + c = static_cast<unsigned char> (*s); + + if (c < 0x80 && !(xml::char_table[c] & xml::name_char_mask)) + ok = false; + } + } + + if (ok) + _characters (value_); + else + _schema_error (schema_error::invalid_name_value); + + if (free_) + { + delete[] const_cast<char*> (value_); + value_ = 0; + } + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/name.hxx b/libxsde/xsde/cxx/serializer/validating/name.hxx new file mode 100644 index 0000000..3c4fe2e --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/name.hxx @@ -0,0 +1,47 @@ +// file : xsde/cxx/serializer/validating/name.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_VALIDATING_NAME_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_NAME_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct name_simpl: virtual name_sskel +#else + struct name_simpl: name_sskel +#endif + { + virtual + ~name_simpl (); + + name_simpl (bool free = false); + + virtual void + pre (const char*); + + virtual void + _serialize_content (); + + protected: + bool free_; + const char* value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/name.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_NAME_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/name.ixx b/libxsde/xsde/cxx/serializer/validating/name.ixx new file mode 100644 index 0000000..84fbdf3 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/name.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/validating/name.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + inline name_simpl:: + name_simpl (bool free) + : free_ (free) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/ncname-stl.cxx b/libxsde/xsde/cxx/serializer/validating/ncname-stl.cxx new file mode 100644 index 0000000..4dec901 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/ncname-stl.cxx @@ -0,0 +1,38 @@ +// file : xsde/cxx/serializer/validating/ncname-stl.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/xml/ncname.hxx> + +#include <xsde/cxx/serializer/validating/ncname-stl.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void ncname_simpl:: + pre (const std::string& value) + { + value_ = value; + } + + void ncname_simpl:: + _serialize_content () + { + std::string tmp; + tmp.swap (value_); + + if (xml::valid_ncname (tmp.c_str (), tmp.size ())) + _characters (tmp.c_str (), tmp.size ()); + else + _schema_error (schema_error::invalid_ncname_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/ncname-stl.hxx b/libxsde/xsde/cxx/serializer/validating/ncname-stl.hxx new file mode 100644 index 0000000..f9bd61d --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/ncname-stl.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/validating/ncname-stl.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_VALIDATING_NCNAME_STL_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_NCNAME_STL_HXX + +#include <string> + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct ncname_simpl: virtual ncname_sskel +#else + struct ncname_simpl: ncname_sskel +#endif + { + virtual void + pre (const std::string&); + + virtual void + _serialize_content (); + + protected: + std::string value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_NCNAME_STL_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/ncname.cxx b/libxsde/xsde/cxx/serializer/validating/ncname.cxx new file mode 100644 index 0000000..9f74a59 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/ncname.cxx @@ -0,0 +1,52 @@ +// file : xsde/cxx/serializer/validating/ncname.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <string.h> // strlen + +#include <xsde/cxx/xml/ncname.hxx> + +#include <xsde/cxx/serializer/validating/ncname.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + ncname_simpl:: + ~ncname_simpl () + { + if (free_) + delete[] const_cast<char*> (value_); + } + + void ncname_simpl:: + pre (const char* value) + { + value_ = value; + } + + void ncname_simpl:: + _serialize_content () + { + size_t n = strlen (value_); + + if (xml::valid_ncname (value_, n)) + _characters (value_, n); + else + _schema_error (schema_error::invalid_ncname_value); + + if (free_) + { + delete[] const_cast<char*> (value_); + value_ = 0; + } + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/ncname.hxx b/libxsde/xsde/cxx/serializer/validating/ncname.hxx new file mode 100644 index 0000000..baafaa4 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/ncname.hxx @@ -0,0 +1,47 @@ +// file : xsde/cxx/serializer/validating/ncname.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_VALIDATING_NCNAME_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_NCNAME_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct ncname_simpl: virtual ncname_sskel +#else + struct ncname_simpl: ncname_sskel +#endif + { + virtual + ~ncname_simpl (); + + ncname_simpl (bool free = false); + + virtual void + pre (const char*); + + virtual void + _serialize_content (); + + protected: + bool free_; + const char* value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/ncname.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_NCNAME_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/ncname.ixx b/libxsde/xsde/cxx/serializer/validating/ncname.ixx new file mode 100644 index 0000000..5d6bf02 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/ncname.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/validating/ncname.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + inline ncname_simpl:: + ncname_simpl (bool free) + : free_ (free) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/negative-integer.cxx b/libxsde/xsde/cxx/serializer/validating/negative-integer.cxx new file mode 100644 index 0000000..bb41770 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/negative-integer.cxx @@ -0,0 +1,51 @@ +// file : xsde/cxx/serializer/validating/negative-integer.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/validating/negative-integer.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void negative_integer_simpl:: + pre (long value) + { + value_ = value; + } + + void negative_integer_simpl:: + _serialize_content () + { + if (value_ >= 0) + { + _schema_error (schema_error::invalid_negative_integer_value); + return; + } + + // We only need strlen("-9223372036854775808") + 1 characters to + // hold all representations of (possibly 64-bit) long. + // + char str[21]; + +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 21, "%ld", value_); +#else + int n = sprintf (str, "%ld", value_); +#endif + if (n > 0 && n < 21) + _characters (str, static_cast<size_t> (n)); + else + _schema_error (schema_error::invalid_negative_integer_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/negative-integer.hxx b/libxsde/xsde/cxx/serializer/validating/negative-integer.hxx new file mode 100644 index 0000000..40fcd80 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/negative-integer.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/validating/negative-integer.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_VALIDATING_NEGATIVE_INTEGER_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_NEGATIVE_INTEGER_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + // Arbitrary-length negative integer. Mapped to long. + // +#ifdef XSDE_REUSE_STYLE_MIXIN + struct negative_integer_simpl: virtual negative_integer_sskel +#else + struct negative_integer_simpl: negative_integer_sskel +#endif + { + virtual void + pre (long); + + virtual void + _serialize_content (); + + protected: + long value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_NEGATIVE_INTEGER_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/nmtoken-stl.cxx b/libxsde/xsde/cxx/serializer/validating/nmtoken-stl.cxx new file mode 100644 index 0000000..c0cf793 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/nmtoken-stl.cxx @@ -0,0 +1,53 @@ +// file : xsde/cxx/serializer/validating/nmtoken-stl.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/xml/char-table.hxx> + +#include <xsde/cxx/serializer/validating/nmtoken-stl.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void nmtoken_simpl:: + pre (const std::string& value) + { + value_ = value; + } + + void nmtoken_simpl:: + _serialize_content () + { + // Make sure we don't hold any references to the string. + // + std::string tmp; + tmp.swap (value_); + + const char* s = tmp.c_str (); + bool ok = (*s != '\0'); + + // For now we are only checking the US-ASCII characters. + // + for (; ok && *s != '\0'; ++s) + { + unsigned char c = static_cast<unsigned char> (*s); + + if (c < 0x80 && !(xml::char_table[c] & xml::name_char_mask)) + ok = false; + } + + if (ok) + _characters (tmp.c_str (), tmp.size ()); + else + _schema_error (schema_error::invalid_nmtoken_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/nmtoken-stl.hxx b/libxsde/xsde/cxx/serializer/validating/nmtoken-stl.hxx new file mode 100644 index 0000000..3de2784 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/nmtoken-stl.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/validating/nmtoken-stl.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_VALIDATING_NMTOKEN_STL_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_NMTOKEN_STL_HXX + +#include <string> + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct nmtoken_simpl: virtual nmtoken_sskel +#else + struct nmtoken_simpl: nmtoken_sskel +#endif + { + virtual void + pre (const std::string&); + + virtual void + _serialize_content (); + + protected: + std::string value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_NMTOKEN_STL_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/nmtoken.cxx b/libxsde/xsde/cxx/serializer/validating/nmtoken.cxx new file mode 100644 index 0000000..2563023 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/nmtoken.cxx @@ -0,0 +1,61 @@ +// file : xsde/cxx/serializer/validating/nmtoken.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/xml/char-table.hxx> + +#include <xsde/cxx/serializer/validating/nmtoken.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + nmtoken_simpl:: + ~nmtoken_simpl () + { + if (free_) + delete[] const_cast<char*> (value_); + } + + void nmtoken_simpl:: + pre (const char* value) + { + value_ = value; + } + + void nmtoken_simpl:: + _serialize_content () + { + const char* s = value_; + bool ok = (*s != '\0'); + + // For now we are only checking the US-ASCII characters. + // + for (; ok && *s != '\0'; ++s) + { + unsigned char c = static_cast<unsigned char> (*s); + + if (c < 0x80 && !(xml::char_table[c] & xml::name_char_mask)) + ok = false; + } + + if (ok) + _characters (value_); + else + _schema_error (schema_error::invalid_nmtoken_value); + + if (free_) + { + delete[] const_cast<char*> (value_); + value_ = 0; + } + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/nmtoken.hxx b/libxsde/xsde/cxx/serializer/validating/nmtoken.hxx new file mode 100644 index 0000000..7951384 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/nmtoken.hxx @@ -0,0 +1,47 @@ +// file : xsde/cxx/serializer/validating/nmtoken.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_VALIDATING_NMTOKEN_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_NMTOKEN_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct nmtoken_simpl: virtual nmtoken_sskel +#else + struct nmtoken_simpl: nmtoken_sskel +#endif + { + virtual + ~nmtoken_simpl (); + + nmtoken_simpl (bool free = false); + + virtual void + pre (const char*); + + virtual void + _serialize_content (); + + protected: + bool free_; + const char* value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/nmtoken.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_NMTOKEN_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/nmtoken.ixx b/libxsde/xsde/cxx/serializer/validating/nmtoken.ixx new file mode 100644 index 0000000..4559310 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/nmtoken.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/validating/nmtoken.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + inline nmtoken_simpl:: + nmtoken_simpl (bool free) + : free_ (free) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/nmtokens-stl.cxx b/libxsde/xsde/cxx/serializer/validating/nmtokens-stl.cxx new file mode 100644 index 0000000..6607177 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/nmtokens-stl.cxx @@ -0,0 +1,109 @@ +// file : xsde/cxx/serializer/validating/nmtokens-stl.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/serializer/validating/nmtokens-stl.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + nmtokens_simpl:: + ~nmtokens_simpl () + { + if (free_) + delete const_cast<string_sequence*> (value_); + } + + void nmtokens_simpl:: + pre (const string_sequence* value) + { + value_ = value; + } + + void nmtokens_simpl:: + _serialize_content () + { + // Should have at least one element. + // + if (!value_->empty ()) + { + bool first = true; + context& ctx = _context (); + + for (string_sequence::const_iterator i (value_->begin ()), + e (value_->end ()); i != e; ++i) + { + serializer_.pre (*i); + +#ifndef XSDE_EXCEPTIONS + if (serializer_._error_type ()) + serializer_._copy_error (ctx); + + if (ctx.error_type ()) + break; +#endif + + if (!first) + { +#ifdef XSDE_EXCEPTIONS + _characters (" ", 1); +#else + if (!_characters (" ", 1)) + break; +#endif + } + else + first = false; + + serializer_._pre_impl (ctx); + + if (ctx.error_type ()) + break; + + serializer_._serialize_content (); + + if (ctx.error_type ()) + break; + + serializer_._post_impl (); + + if (ctx.error_type ()) + break; + + serializer_.post (); + +#ifndef XSDE_EXCEPTIONS + if (serializer_._error_type ()) + serializer_._copy_error (ctx); + + if (ctx.error_type ()) + break; +#endif + } + } + else + _schema_error (schema_error::invalid_nmtokens_value); + + if (free_) + { + delete const_cast<string_sequence*> (value_); + value_ = 0; + } + } + + void nmtokens_simpl:: + _reset () + { + nmtokens_sskel::_reset (); + serializer_._reset (); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/nmtokens-stl.hxx b/libxsde/xsde/cxx/serializer/validating/nmtokens-stl.hxx new file mode 100644 index 0000000..aab3fae --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/nmtokens-stl.hxx @@ -0,0 +1,52 @@ +// file : xsde/cxx/serializer/validating/nmtokens-stl.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_VALIDATING_NMTOKENS_STL_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_NMTOKENS_STL_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> +#include <xsde/cxx/serializer/validating/nmtoken-stl.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct nmtokens_simpl: virtual nmtokens_sskel +#else + struct nmtokens_simpl: nmtokens_sskel +#endif + { + virtual + ~nmtokens_simpl (); + + nmtokens_simpl (bool free = false); + + virtual void + pre (const string_sequence*); + + virtual void + _serialize_content (); + + virtual void + _reset (); + + protected: + bool free_; + const string_sequence* value_; + nmtoken_simpl serializer_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/nmtokens-stl.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_NMTOKENS_STL_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/nmtokens-stl.ixx b/libxsde/xsde/cxx/serializer/validating/nmtokens-stl.ixx new file mode 100644 index 0000000..988c9cd --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/nmtokens-stl.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/validating/nmtokens-stl.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + inline nmtokens_simpl:: + nmtokens_simpl (bool free) + : free_ (free), value_ (0) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/nmtokens.cxx b/libxsde/xsde/cxx/serializer/validating/nmtokens.cxx new file mode 100644 index 0000000..74e111b --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/nmtokens.cxx @@ -0,0 +1,110 @@ +// file : xsde/cxx/serializer/validating/nmtokens.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/serializer/validating/nmtokens.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + nmtokens_simpl:: + ~nmtokens_simpl () + { + if (free_) + delete const_cast<string_sequence*> (value_); + } + + void nmtokens_simpl:: + pre (const string_sequence* value) + { + value_ = value; + } + + void nmtokens_simpl:: + _serialize_content () + { + // Should have at least one element. + // + if (!value_->empty ()) + { + bool first = true; + context& ctx = _context (); + + for (string_sequence::const_iterator i (value_->begin ()), + e (value_->end ()); i != e; ++i) + { + serializer_.pre (*i); + +#ifndef XSDE_EXCEPTIONS + if (serializer_._error_type ()) + serializer_._copy_error (ctx); + + if (ctx.error_type ()) + break; +#endif + + if (!first) + { +#ifdef XSDE_EXCEPTIONS + _characters (" ", 1); +#else + if (!_characters (" ", 1)) + break; +#endif + } + else + first = false; + + serializer_._pre_impl (ctx); + + if (ctx.error_type ()) + break; + + serializer_._serialize_content (); + + if (ctx.error_type ()) + break; + + serializer_._post_impl (); + + if (ctx.error_type ()) + break; + + serializer_.post (); + +#ifndef XSDE_EXCEPTIONS + if (serializer_._error_type ()) + serializer_._copy_error (ctx); + + if (ctx.error_type ()) + break; +#endif + } + } + else + _schema_error (schema_error::invalid_nmtokens_value); + + if (free_) + { + delete const_cast<string_sequence*> (value_); + value_ = 0; + } + } + + void nmtokens_simpl:: + _reset () + { + nmtokens_sskel::_reset (); + serializer_._reset (); + } + } + } + } +} + diff --git a/libxsde/xsde/cxx/serializer/validating/nmtokens.hxx b/libxsde/xsde/cxx/serializer/validating/nmtokens.hxx new file mode 100644 index 0000000..525ab13 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/nmtokens.hxx @@ -0,0 +1,52 @@ +// file : xsde/cxx/serializer/validating/nmtokens.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_VALIDATING_NMTOKENS_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_NMTOKENS_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> +#include <xsde/cxx/serializer/validating/nmtoken.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct nmtokens_simpl: virtual nmtokens_sskel +#else + struct nmtokens_simpl: nmtokens_sskel +#endif + { + virtual + ~nmtokens_simpl (); + + nmtokens_simpl (bool free = false); + + virtual void + pre (const string_sequence*); + + virtual void + _serialize_content (); + + virtual void + _reset (); + + protected: + bool free_; + const string_sequence* value_; + nmtoken_simpl serializer_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/nmtokens.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_NMTOKENS_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/nmtokens.ixx b/libxsde/xsde/cxx/serializer/validating/nmtokens.ixx new file mode 100644 index 0000000..0526e30 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/nmtokens.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/validating/nmtokens.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + inline nmtokens_simpl:: + nmtokens_simpl (bool free) + : free_ (free), value_ (0), serializer_ (false) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/non-negative-integer.cxx b/libxsde/xsde/cxx/serializer/validating/non-negative-integer.cxx new file mode 100644 index 0000000..87a6e22 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/non-negative-integer.cxx @@ -0,0 +1,45 @@ +// file : xsde/cxx/serializer/validating/non-negative-integer.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/validating/non-negative-integer.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void non_negative_integer_simpl:: + pre (unsigned long value) + { + value_ = value; + } + + void non_negative_integer_simpl:: + _serialize_content () + { + // We only need strlen("18446744073709551615") + 1 characters to + // hold all representations of (possibly 64-bit) unsigned long. + // + char str[21]; + +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 21, "%lu", value_); +#else + int n = sprintf (str, "%lu", value_); +#endif + if (n > 0 && n < 21) + _characters (str, static_cast<size_t> (n)); + else + _schema_error (schema_error::invalid_non_negative_integer_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/non-negative-integer.hxx b/libxsde/xsde/cxx/serializer/validating/non-negative-integer.hxx new file mode 100644 index 0000000..8d5b769 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/non-negative-integer.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/validating/non-negative-integer.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_VALIDATING_NON_NEGATIVE_INTEGER_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_NON_NEGATIVE_INTEGER_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + // Arbitrary-length non-negative integer. Mapped to unsigned long. + // +#ifdef XSDE_REUSE_STYLE_MIXIN + struct non_negative_integer_simpl: virtual non_negative_integer_sskel +#else + struct non_negative_integer_simpl: non_negative_integer_sskel +#endif + { + virtual void + pre (unsigned long); + + virtual void + _serialize_content (); + + protected: + unsigned long value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_NON_NEGATIVE_INTEGER_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/non-positive-integer.cxx b/libxsde/xsde/cxx/serializer/validating/non-positive-integer.cxx new file mode 100644 index 0000000..bbd2854 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/non-positive-integer.cxx @@ -0,0 +1,51 @@ +// file : xsde/cxx/serializer/validating/non-positive-integer.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/validating/non-positive-integer.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void non_positive_integer_simpl:: + pre (long value) + { + value_ = value; + } + + void non_positive_integer_simpl:: + _serialize_content () + { + if (value_ > 0) + { + _schema_error (schema_error::invalid_non_positive_integer_value); + return; + } + + // We only need strlen("-9223372036854775808") + 1 characters to + // hold all representations of (possibly 64-bit) long. + // + char str[21]; + +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 21, "%ld", value_); +#else + int n = sprintf (str, "%ld", value_); +#endif + if (n > 0 && n < 21) + _characters (str, static_cast<size_t> (n)); + else + _schema_error (schema_error::invalid_non_positive_integer_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/non-positive-integer.hxx b/libxsde/xsde/cxx/serializer/validating/non-positive-integer.hxx new file mode 100644 index 0000000..9defbba --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/non-positive-integer.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/validating/non-positive-integer.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_VALIDATING_NON_POSITIVE_INTEGER_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_NON_POSITIVE_INTEGER_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + // Arbitrary-length non-positive integer. Mapped to long. + // +#ifdef XSDE_REUSE_STYLE_MIXIN + struct non_positive_integer_simpl: virtual non_positive_integer_sskel +#else + struct non_positive_integer_simpl: non_positive_integer_sskel +#endif + { + virtual void + pre (long); + + virtual void + _serialize_content (); + + protected: + long value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_NON_POSITIVE_INTEGER_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/normalized-string-stl.cxx b/libxsde/xsde/cxx/serializer/validating/normalized-string-stl.cxx new file mode 100644 index 0000000..7c945da --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/normalized-string-stl.cxx @@ -0,0 +1,47 @@ +// file : xsde/cxx/serializer/validating/normalized-string-stl.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/serializer/validating/normalized-string-stl.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void normalized_string_simpl:: + pre (const std::string& value) + { + value_ = value; + } + + void normalized_string_simpl:: + _serialize_content () + { + // Make sure we don't hold any references to the string. + // + std::string tmp; + tmp.swap (value_); + + const char* s = tmp.c_str (); + + for (; *s != '\0'; ++s) + { + if (*s == 0x0A || *s == 0x0D || *s == 0x09) + break; + } + + if (*s == '\0') + _characters (tmp.c_str (), tmp.size ()); + else + _schema_error (schema_error::invalid_normalized_string_value); + } + } + } + } +} + diff --git a/libxsde/xsde/cxx/serializer/validating/normalized-string-stl.hxx b/libxsde/xsde/cxx/serializer/validating/normalized-string-stl.hxx new file mode 100644 index 0000000..98ae359 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/normalized-string-stl.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/validating/normalized-string-stl.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_VALIDATING_NORMALIZED_STRING_STL_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_NORMALIZED_STRING_STL_HXX + +#include <string> + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct normalized_string_simpl: virtual normalized_string_sskel +#else + struct normalized_string_simpl: normalized_string_sskel +#endif + { + virtual void + pre (const std::string&); + + virtual void + _serialize_content (); + + protected: + std::string value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_NORMALIZED_STRING_STL_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/normalized-string.cxx b/libxsde/xsde/cxx/serializer/validating/normalized-string.cxx new file mode 100644 index 0000000..1e29376 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/normalized-string.cxx @@ -0,0 +1,55 @@ +// file : xsde/cxx/serializer/validating/normalized-string.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/serializer/validating/normalized-string.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + normalized_string_simpl:: + ~normalized_string_simpl () + { + if (free_) + delete[] const_cast<char*> (value_); + } + + void normalized_string_simpl:: + pre (const char* value) + { + value_ = value; + } + + void normalized_string_simpl:: + _serialize_content () + { + const char* s = value_; + + for (; *s != '\0'; ++s) + { + if (*s == 0x0A || *s == 0x0D || *s == 0x09) + break; + } + + if (*s == '\0') + _characters (value_); + else + _schema_error (schema_error::invalid_normalized_string_value); + + if (free_) + { + delete[] const_cast<char*> (value_); + value_ = 0; + } + } + } + } + } +} + diff --git a/libxsde/xsde/cxx/serializer/validating/normalized-string.hxx b/libxsde/xsde/cxx/serializer/validating/normalized-string.hxx new file mode 100644 index 0000000..6496ab9 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/normalized-string.hxx @@ -0,0 +1,47 @@ +// file : xsde/cxx/serializer/validating/normalized-string.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_VALIDATING_NORMALIZED_STRING_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_NORMALIZED_STRING_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct normalized_string_simpl: virtual normalized_string_sskel +#else + struct normalized_string_simpl: normalized_string_sskel +#endif + { + virtual + ~normalized_string_simpl (); + + normalized_string_simpl (bool free = false); + + virtual void + pre (const char*); + + virtual void + _serialize_content (); + + protected: + bool free_; + const char* value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/normalized-string.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_NORMALIZED_STRING_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/normalized-string.ixx b/libxsde/xsde/cxx/serializer/validating/normalized-string.ixx new file mode 100644 index 0000000..dc9085f --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/normalized-string.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/validating/normalized-string.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + inline normalized_string_simpl:: + normalized_string_simpl (bool free) + : free_ (free) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/positive-integer.cxx b/libxsde/xsde/cxx/serializer/validating/positive-integer.cxx new file mode 100644 index 0000000..dbb83cd --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/positive-integer.cxx @@ -0,0 +1,51 @@ +// file : xsde/cxx/serializer/validating/positive-integer.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/validating/positive-integer.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void positive_integer_simpl:: + pre (unsigned long value) + { + value_ = value; + } + + void positive_integer_simpl:: + _serialize_content () + { + if (value_ == 0) + { + _schema_error (schema_error::invalid_positive_integer_value); + return; + } + + // We only need strlen("18446744073709551615") + 1 characters to + // hold all representations of (possibly 64-bit) unsigned long. + // + char str[21]; + +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 21, "%lu", value_); +#else + int n = sprintf (str, "%lu", value_); +#endif + if (n > 0 && n < 21) + _characters (str, static_cast<size_t> (n)); + else + _schema_error (schema_error::invalid_positive_integer_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/positive-integer.hxx b/libxsde/xsde/cxx/serializer/validating/positive-integer.hxx new file mode 100644 index 0000000..329145e --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/positive-integer.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/validating/positive-integer.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_VALIDATING_POSITIVE_INTEGER_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_POSITIVE_INTEGER_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + // Arbitrary-length positive integer. Mapped to unsigned long. + // +#ifdef XSDE_REUSE_STYLE_MIXIN + struct positive_integer_simpl: virtual positive_integer_sskel +#else + struct positive_integer_simpl: positive_integer_sskel +#endif + { + virtual void + pre (unsigned long); + + virtual void + _serialize_content (); + + protected: + unsigned long value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_POSITIVE_INTEGER_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/qname-stl.cxx b/libxsde/xsde/cxx/serializer/validating/qname-stl.cxx new file mode 100644 index 0000000..0e48748 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/qname-stl.cxx @@ -0,0 +1,68 @@ +// file : xsde/cxx/serializer/validating/qname-stl.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/xml/ncname.hxx> + +#include <xsde/cxx/serializer/validating/qname-stl.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void qname_simpl:: + pre (const qname& value) + { + value_ = value; + } + + void qname_simpl:: + _serialize_content () + { + // Make sure we don't hold any references to the qname. + // + qname tmp ("a"); + tmp.swap (value_); + + const char* ns = tmp.name ().c_str (); + size_t nn = tmp.name ().size (); + + if (!tmp.prefix ().empty ()) + { + const char* ps = tmp.prefix ().c_str (); + size_t pn = tmp.prefix ().size (); + + if (xml::valid_ncname (ps, pn) && xml::valid_ncname (ns, nn)) + { +#ifdef XSDE_EXCEPTIONS + _characters (ps, pn); + _characters (":", 1); + _characters (ns, nn); +#else + if (_characters (ps, pn)) + { + if (_characters (":", 1)) + _characters (ns, nn); + } +#endif + } + else + _schema_error (schema_error::invalid_qname_value); + } + else + { + if (xml::valid_ncname (ns, nn)) + _characters (ns, nn); + else + _schema_error (schema_error::invalid_qname_value); + } + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/qname-stl.hxx b/libxsde/xsde/cxx/serializer/validating/qname-stl.hxx new file mode 100644 index 0000000..8d87a4b --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/qname-stl.hxx @@ -0,0 +1,43 @@ +// file : xsde/cxx/serializer/validating/qname-stl.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_VALIDATING_QNAME_STL_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_QNAME_STL_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct qname_simpl: virtual qname_sskel +#else + struct qname_simpl: qname_sskel +#endif + { + qname_simpl (); + + virtual void + pre (const qname&); + + virtual void + _serialize_content (); + + protected: + qname value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/qname-stl.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_QNAME_STL_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/qname-stl.ixx b/libxsde/xsde/cxx/serializer/validating/qname-stl.ixx new file mode 100644 index 0000000..99edfdd --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/qname-stl.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/validating/qname-stl.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + inline qname_simpl:: + qname_simpl () + : value_ ("a") + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/qname.cxx b/libxsde/xsde/cxx/serializer/validating/qname.cxx new file mode 100644 index 0000000..b69eb54 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/qname.cxx @@ -0,0 +1,79 @@ +// file : xsde/cxx/serializer/validating/qname.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <string.h> // strlen + +#include <xsde/cxx/xml/ncname.hxx> + +#include <xsde/cxx/serializer/validating/qname.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + qname_simpl:: + ~qname_simpl () + { + if (free_) + delete const_cast<qname*> (value_); + } + + void qname_simpl:: + pre (const qname* value) + { + value_ = value; + } + + void qname_simpl:: + _serialize_content () + { + const char* ns = value_->name (); + size_t nn = strlen (ns); + + const char* ps = value_->prefix (); + + if (ps != 0 && *ps != '\0') + { + size_t pn = strlen (ps); + + if (xml::valid_ncname (ps, pn) && xml::valid_ncname (ns, nn)) + { +#ifdef XSDE_EXCEPTIONS + _characters (ps, pn); + _characters (":", 1); + _characters (ns, nn); +#else + if (_characters (ps, pn)) + { + if (_characters (":", 1)) + _characters (ns, nn); + } +#endif + } + else + _schema_error (schema_error::invalid_qname_value); + } + else + { + if (xml::valid_ncname (ns, nn)) + _characters (ns, nn); + else + _schema_error (schema_error::invalid_qname_value); + } + + if (free_) + { + delete const_cast<qname*> (value_); + value_ = 0; + } + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/qname.hxx b/libxsde/xsde/cxx/serializer/validating/qname.hxx new file mode 100644 index 0000000..e9790f5 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/qname.hxx @@ -0,0 +1,47 @@ +// file : xsde/cxx/serializer/validating/qname.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_VALIDATING_QNAME_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_QNAME_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct qname_simpl: virtual qname_sskel +#else + struct qname_simpl: qname_sskel +#endif + { + virtual + ~qname_simpl (); + + qname_simpl (bool free = false); + + virtual void + pre (const qname*); + + virtual void + _serialize_content (); + + protected: + bool free_; + const qname* value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/qname.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_QNAME_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/qname.ixx b/libxsde/xsde/cxx/serializer/validating/qname.ixx new file mode 100644 index 0000000..08d69d1 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/qname.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/validating/qname.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + inline qname_simpl:: + qname_simpl (bool free) + : free_ (free), value_ (0) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/serializer.cxx b/libxsde/xsde/cxx/serializer/validating/serializer.cxx new file mode 100644 index 0000000..280c09f --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/serializer.cxx @@ -0,0 +1,29 @@ +// file : xsde/cxx/serializer/validating/serializer.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/serializer/validating/serializer.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + // simple_content + // +#ifdef XSDE_REUSE_STYLE_TIEIN + void simple_content:: + _serialize_content () + { + if (impl_) + impl_->_serialize_content (); + } +#endif + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/serializer.hxx b/libxsde/xsde/cxx/serializer/validating/serializer.hxx new file mode 100644 index 0000000..d8ba64c --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/serializer.hxx @@ -0,0 +1,58 @@ +// file : xsde/cxx/serializer/validating/serializer.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_VALIDATING_SERIALIZER_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_SERIALIZER_HXX + +#include <xsde/cxx/config.hxx> + +#include <xsde/cxx/serializer/elements.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + struct empty_content: serializer_base + { +#ifdef XSDE_REUSE_STYLE_TIEIN + empty_content (); + empty_content (empty_content* impl, void*); +#endif + }; + + // + // + struct simple_content: empty_content + { +#ifdef XSDE_REUSE_STYLE_TIEIN + virtual void + _serialize_content (); + + simple_content (); + simple_content (simple_content* impl, void*); +#endif + }; + + // + // + struct complex_content: empty_content + { +#ifdef XSDE_REUSE_STYLE_TIEIN + complex_content (); + complex_content (complex_content* impl, void*); +#endif + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/serializer.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_SERIALIZER_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/serializer.ixx b/libxsde/xsde/cxx/serializer/validating/serializer.ixx new file mode 100644 index 0000000..66b9ad7 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/serializer.ixx @@ -0,0 +1,61 @@ +// file : xsde/cxx/serializer/validating/serializer.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + // empty_content + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline empty_content:: + empty_content () + { + } + + inline empty_content:: + empty_content (empty_content* impl, void*) + : serializer_base (impl, 0) + { + } +#endif + + // simple_content + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline simple_content:: + simple_content () + { + } + + inline simple_content:: + simple_content (simple_content* impl, void*) + : empty_content (impl, 0) + { + } +#endif + + // complex_content + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline complex_content:: + complex_content () + { + } + + inline complex_content:: + complex_content (complex_content* impl, void*) + : empty_content (impl, 0) + { + } +#endif + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/short.cxx b/libxsde/xsde/cxx/serializer/validating/short.cxx new file mode 100644 index 0000000..61e7132 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/short.cxx @@ -0,0 +1,45 @@ +// file : xsde/cxx/serializer/validating/short.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/validating/short.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void short_simpl:: + pre (short value) + { + value_ = value; + } + + void short_simpl:: + _serialize_content () + { + // We only need strlen("-32768") + 1 characters to hold all + // representations of short. + // + char str[7]; + +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 7, "%d", value_); +#else + int n = sprintf (str, "%d", value_); +#endif + if (n > 0 && n < 7) + _characters (str, static_cast<size_t> (n)); + else + _schema_error (schema_error::invalid_short_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/short.hxx b/libxsde/xsde/cxx/serializer/validating/short.hxx new file mode 100644 index 0000000..51da86f --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/short.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/validating/short.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_VALIDATING_SHORT_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_SHORT_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + // 16-bit signed integer + // +#ifdef XSDE_REUSE_STYLE_MIXIN + struct short_simpl: virtual short_sskel +#else + struct short_simpl: short_sskel +#endif + { + virtual void + pre (short); + + virtual void + _serialize_content (); + + protected: + short value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_SHORT_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/string-stl.cxx b/libxsde/xsde/cxx/serializer/validating/string-stl.cxx new file mode 100644 index 0000000..a70533f --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/string-stl.cxx @@ -0,0 +1,35 @@ +// file : xsde/cxx/serializer/validating/string-stl.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/serializer/validating/string-stl.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void string_simpl:: + pre (const std::string& value) + { + value_ = value; + } + + void string_simpl:: + _serialize_content () + { + // Make sure we don't hold any references to the string. + // + std::string tmp; + tmp.swap (value_); + + _characters (tmp.c_str (), tmp.size ()); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/string-stl.hxx b/libxsde/xsde/cxx/serializer/validating/string-stl.hxx new file mode 100644 index 0000000..74f55cc --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/string-stl.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/validating/string-stl.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_VALIDATING_STRING_STL_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_STRING_STL_HXX + +#include <string> + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct string_simpl: virtual string_sskel +#else + struct string_simpl: string_sskel +#endif + { + virtual void + pre (const std::string&); + + virtual void + _serialize_content (); + + protected: + std::string value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_STRING_STL_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/string.cxx b/libxsde/xsde/cxx/serializer/validating/string.cxx new file mode 100644 index 0000000..b8a4068 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/string.cxx @@ -0,0 +1,43 @@ +// file : xsde/cxx/serializer/validating/string.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/serializer/validating/string.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + string_simpl:: + ~string_simpl () + { + if (free_) + delete[] const_cast<char*> (value_); + } + + void string_simpl:: + pre (const char* value) + { + value_ = value; + } + + void string_simpl:: + _serialize_content () + { + _characters (value_); + + if (free_) + { + delete[] const_cast<char*> (value_); + value_ = 0; + } + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/string.hxx b/libxsde/xsde/cxx/serializer/validating/string.hxx new file mode 100644 index 0000000..5385355 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/string.hxx @@ -0,0 +1,47 @@ +// file : xsde/cxx/serializer/validating/string.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_VALIDATING_STRING_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_STRING_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct string_simpl: virtual string_sskel +#else + struct string_simpl: string_sskel +#endif + { + virtual + ~string_simpl (); + + string_simpl (bool free = false); + + virtual void + pre (const char*); + + virtual void + _serialize_content (); + + protected: + bool free_; + const char* value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/string.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_STRING_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/string.ixx b/libxsde/xsde/cxx/serializer/validating/string.ixx new file mode 100644 index 0000000..a23e517 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/string.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/validating/string.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + inline string_simpl:: + string_simpl (bool free) + : free_ (free), value_ (0) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/time-zone.cxx b/libxsde/xsde/cxx/serializer/validating/time-zone.cxx new file mode 100644 index 0000000..ae28d70 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/time-zone.cxx @@ -0,0 +1,65 @@ +// file : xsde/cxx/serializer/validating/time-zone.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/config.hxx> + +#include <xsde/cxx/serializer/validating/time-zone.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + namespace bits + { + int + serialize_time_zone (char* s, const time_zone& z) + { + // time-zone := Z|(+|-)HH:MM + // + + short h = z.zone_hours (); + short m = z.zone_minutes (); + + if (h == 0 && m == 0) + { + *s = 'Z'; + return 1; + } + else + { + const char* fmt = "+%.2u:%.2u"; + + if (h < 0) + { + fmt = "-%.2u:%.2u"; + h = -h; + m = -m; + } + + if (h >= 0 && h <= 14 && m >= 0 && m <= 59) + { +#ifdef XSDE_SNPRINTF + int n = snprintf (s, 7, fmt, h, m); +#else + int n = sprintf (s, fmt, h, m); +#endif + if (n > 0 && n < 7) + return n; + } + + return 0; + } + } + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/time-zone.hxx b/libxsde/xsde/cxx/serializer/validating/time-zone.hxx new file mode 100644 index 0000000..27784cf --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/time-zone.hxx @@ -0,0 +1,40 @@ +// file : xsde/cxx/serializer/validating/time-zone.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_VALIDATING_TIME_ZONE_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_TIME_ZONE_HXX + +#include <xsde/cxx/date-time.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + namespace bits + { + bool + valid_time_zone (const time_zone&); + + // Returns 0 in case of a failure and the number of + // characters written otherwise. The buffer should + // have space for at least 7 characters. Note that + // this function expects that the time zone was + // verified by valid_time_zone() above. + // + int + serialize_time_zone (char* s, const time_zone&); + } + } + } + } +} + +#include <xsde/cxx/serializer/validating/time-zone.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_TIME_ZONE_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/time-zone.ixx b/libxsde/xsde/cxx/serializer/validating/time-zone.ixx new file mode 100644 index 0000000..c6e80f4 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/time-zone.ixx @@ -0,0 +1,32 @@ +// file : xsde/cxx/serializer/validating/time-zone.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + namespace bits + { + inline bool + valid_time_zone (const time_zone& z) + { + short h = z.zone_hours (); + short m = z.zone_minutes (); + + unsigned short ah = h < 0 ? -h : h; + unsigned short am = m < 0 ? -m : m; + + return ((h <= 0 && m <= 0) || (h >= 0 && m >= 0)) && + ((ah < 14 && am < 60) || (ah == 14 && am == 0)); + } + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/time.cxx b/libxsde/xsde/cxx/serializer/validating/time.cxx new file mode 100644 index 0000000..5ab5c22 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/time.cxx @@ -0,0 +1,79 @@ +// file : xsde/cxx/serializer/validating/time.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/validating/time.hxx> +#include <xsde/cxx/serializer/validating/time-zone.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void time_simpl:: + pre (const time& value) + { + value_ = value; + } + + void time_simpl:: + _serialize_content () + { + // We only need strlen("hh:mm:ss.ssssss-hh:mm") + 1 characters to + // hold all representations of time. We know that the seconds + // part (represented as double) has default precision of 6. + // + char str[22]; + + unsigned short h = value_.hours (); + unsigned short m = value_.minutes (); + double s = value_.seconds (); + + if (((h < 24 && m < 60 && s >= 0.0 && s < 60.0) || + (h == 24 && m == 0 && s == 0.0)) && + (!value_.zone_present () || bits::valid_time_zone (value_))) + { +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 16, "%.2u:%.2u:%09f", h, m, s); +#else + int n = sprintf (str, "%.2u:%.2u:%09f", h, m, s); +#endif + if (n > 0 && n < 16) + { + // Remove trailing '0' and '.' if necessary. + // + while (str[n - 1] == '0') + n--; + + if (str[n - 1] == '.') + n--; + + if (value_.zone_present ()) + { + if (int z = bits::serialize_time_zone (str + n, value_)) + n += z; + else + { + _schema_error (schema_error::invalid_time_value); + return; + } + } + + _characters (str, static_cast<size_t> (n)); + } + else + _schema_error (schema_error::invalid_time_value); + } + else + _schema_error (schema_error::invalid_time_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/time.hxx b/libxsde/xsde/cxx/serializer/validating/time.hxx new file mode 100644 index 0000000..1eedc7a --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/time.hxx @@ -0,0 +1,43 @@ +// file : xsde/cxx/serializer/validating/time.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_VALIDATING_TIME_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_TIME_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct time_simpl: virtual time_sskel +#else + struct time_simpl: time_sskel +#endif + { + time_simpl (); + + virtual void + pre (const time&); + + virtual void + _serialize_content (); + + protected: + time value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/time.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_TIME_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/time.ixx b/libxsde/xsde/cxx/serializer/validating/time.ixx new file mode 100644 index 0000000..5262419 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/time.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/validating/time.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + inline time_simpl:: + time_simpl () + : value_ (0, 0, 0.0) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/token-stl.cxx b/libxsde/xsde/cxx/serializer/validating/token-stl.cxx new file mode 100644 index 0000000..0de2a54 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/token-stl.cxx @@ -0,0 +1,58 @@ +// file : xsde/cxx/serializer/validating/token-stl.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/serializer/validating/token-stl.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void token_simpl:: + pre (const std::string& value) + { + value_ = value; + } + + void token_simpl:: + _serialize_content () + { + // Make sure we don't hold any references to the string. + // + std::string tmp; + tmp.swap (value_); + + bool ok = true; + const char* s = tmp.c_str (); + + // No leading whitespaces. + // + if (*s == 0x20) + ok = false; + + for (; ok && *s != '\0'; ++s) + { + if (*s == 0x0A || *s == 0x0D || *s == 0x09 || + (*s == 0x20 && *(s + 1) == 0x20)) + ok = false; + } + + // No trailing whitespaces. + // + if (ok && s != tmp.c_str () && *(s - 1) == 0x20) + ok = false; + + if (ok) + _characters (tmp.c_str (), tmp.size ()); + else + _schema_error (schema_error::invalid_token_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/token-stl.hxx b/libxsde/xsde/cxx/serializer/validating/token-stl.hxx new file mode 100644 index 0000000..6de5f1e --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/token-stl.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/validating/token-stl.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_VALIDATING_TOKEN_STL_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_TOKEN_STL_HXX + +#include <string> + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct token_simpl: virtual token_sskel +#else + struct token_simpl: token_sskel +#endif + { + virtual void + pre (const std::string&); + + virtual void + _serialize_content (); + + protected: + std::string value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_TOKEN_STL_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/token.cxx b/libxsde/xsde/cxx/serializer/validating/token.cxx new file mode 100644 index 0000000..76bbce4 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/token.cxx @@ -0,0 +1,66 @@ +// file : xsde/cxx/serializer/validating/token.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/serializer/validating/token.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + token_simpl:: + ~token_simpl () + { + if (free_) + delete[] const_cast<char*> (value_); + } + + void token_simpl:: + pre (const char* value) + { + value_ = value; + } + + void token_simpl:: + _serialize_content () + { + bool ok = true; + const char* s = value_; + + // No leading whitespaces. + // + if (*s == 0x20) + ok = false; + + for (; ok && *s != '\0'; ++s) + { + if (*s == 0x0A || *s == 0x0D || *s == 0x09 || + (*s == 0x20 && *(s + 1) == 0x20)) + ok = false; + } + + // No trailing whitespaces. + // + if (ok && s != value_ && *(s - 1) == 0x20) + ok = false; + + if (ok) + _characters (value_); + else + _schema_error (schema_error::invalid_token_value); + + if (free_) + { + delete[] const_cast<char*> (value_); + value_ = 0; + } + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/token.hxx b/libxsde/xsde/cxx/serializer/validating/token.hxx new file mode 100644 index 0000000..3b3c099 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/token.hxx @@ -0,0 +1,47 @@ +// file : xsde/cxx/serializer/validating/token.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_VALIDATING_TOKEN_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_TOKEN_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct token_simpl: virtual token_sskel +#else + struct token_simpl: token_sskel +#endif + { + virtual + ~token_simpl (); + + token_simpl (bool free = false); + + virtual void + pre (const char*); + + virtual void + _serialize_content (); + + protected: + bool free_; + const char* value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/token.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_TOKEN_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/token.ixx b/libxsde/xsde/cxx/serializer/validating/token.ixx new file mode 100644 index 0000000..30d119c --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/token.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/validating/token.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + inline token_simpl:: + token_simpl (bool free) + : free_ (free) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/unsigned-byte.cxx b/libxsde/xsde/cxx/serializer/validating/unsigned-byte.cxx new file mode 100644 index 0000000..97b45f3 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/unsigned-byte.cxx @@ -0,0 +1,45 @@ +// file : xsde/cxx/serializer/validating/unsigned-byte.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/validating/unsigned-byte.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void unsigned_byte_simpl:: + pre (unsigned char value) + { + value_ = value; + } + + void unsigned_byte_simpl:: + _serialize_content () + { + // We only need strlen("256") + 1 characters to hold all + // representations of unsigned byte. + // + char str[4]; + +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 4, "%u", value_); +#else + int n = sprintf (str, "%u", value_); +#endif + if (n > 0 && n < 4) + _characters (str, static_cast<size_t> (n)); + else + _schema_error (schema_error::invalid_unsigned_byte_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/unsigned-byte.hxx b/libxsde/xsde/cxx/serializer/validating/unsigned-byte.hxx new file mode 100644 index 0000000..1afa8db --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/unsigned-byte.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/validating/unsigned-byte.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_VALIDATING_UNSIGNED_BYTE_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_UNSIGNED_BYTE_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + // 8-bit unsigned integer + // +#ifdef XSDE_REUSE_STYLE_MIXIN + struct unsigned_byte_simpl: virtual unsigned_byte_sskel +#else + struct unsigned_byte_simpl: unsigned_byte_sskel +#endif + { + virtual void + pre (unsigned char); + + virtual void + _serialize_content (); + + protected: + unsigned char value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_UNSIGNED_BYTE_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/unsigned-int.cxx b/libxsde/xsde/cxx/serializer/validating/unsigned-int.cxx new file mode 100644 index 0000000..14e478f --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/unsigned-int.cxx @@ -0,0 +1,45 @@ +// file : xsde/cxx/serializer/validating/unsigned-int.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/validating/unsigned-int.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void unsigned_int_simpl:: + pre (unsigned int value) + { + value_ = value; + } + + void unsigned_int_simpl:: + _serialize_content () + { + // We only need strlen("4294967295") + 1 characters to hold all + // representations of unsigned int. + // + char str[11]; + +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 11, "%u", value_); +#else + int n = sprintf (str, "%u", value_); +#endif + if (n > 0 && n < 11) + _characters (str, static_cast<size_t> (n)); + else + _schema_error (schema_error::invalid_unsigned_int_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/unsigned-int.hxx b/libxsde/xsde/cxx/serializer/validating/unsigned-int.hxx new file mode 100644 index 0000000..fb103cd --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/unsigned-int.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/validating/unsigned-int.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_VALIDATING_UNSIGNED_INT_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_UNSIGNED_INT_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + // 32-bit unsigned integer + // +#ifdef XSDE_REUSE_STYLE_MIXIN + struct unsigned_int_simpl: virtual unsigned_int_sskel +#else + struct unsigned_int_simpl: unsigned_int_sskel +#endif + { + virtual void + pre (unsigned int); + + virtual void + _serialize_content (); + + protected: + unsigned int value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_UNSIGNED_INT_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/unsigned-long-long.cxx b/libxsde/xsde/cxx/serializer/validating/unsigned-long-long.cxx new file mode 100644 index 0000000..3520b31 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/unsigned-long-long.cxx @@ -0,0 +1,45 @@ +// file : xsde/cxx/serializer/validating/unsigned-long-long.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/validating/unsigned-long-long.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void unsigned_long_simpl:: + pre (unsigned long long value) + { + value_ = value; + } + + void unsigned_long_simpl:: + _serialize_content () + { + // We only need strlen("18446744073709551615") + 1 characters to + // hold all representations of unsigned long long. + // + char str[21]; + +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 21, "%llu", value_); +#else + int n = sprintf (str, "%llu", value_); +#endif + if (n > 0 && n < 21) + _characters (str, static_cast<size_t> (n)); + else + _schema_error (schema_error::invalid_unsigned_long_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/unsigned-long-long.hxx b/libxsde/xsde/cxx/serializer/validating/unsigned-long-long.hxx new file mode 100644 index 0000000..8a746e3 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/unsigned-long-long.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/validating/unsigned-long-long.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_VALIDATING_UNSIGNED_LONG_LONG_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_UNSIGNED_LONG_LONG_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + // 64-bit unsigned integer + // +#ifdef XSDE_REUSE_STYLE_MIXIN + struct unsigned_long_simpl: virtual unsigned_long_sskel +#else + struct unsigned_long_simpl: unsigned_long_sskel +#endif + { + virtual void + pre (unsigned long long); + + virtual void + _serialize_content (); + + protected: + unsigned long long value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_UNSIGNED_LONG_LONG_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/unsigned-long.cxx b/libxsde/xsde/cxx/serializer/validating/unsigned-long.cxx new file mode 100644 index 0000000..b34d8aa --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/unsigned-long.cxx @@ -0,0 +1,45 @@ +// file : xsde/cxx/serializer/validating/unsigned-long.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/validating/unsigned-long.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void unsigned_long_simpl:: + pre (unsigned long value) + { + value_ = value; + } + + void unsigned_long_simpl:: + _serialize_content () + { + // We only need strlen("18446744073709551615") + 1 characters to + // hold all representations of (possibly 64-bit) unsigned long. + // + char str[21]; + +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 21, "%lu", value_); +#else + int n = sprintf (str, "%lu", value_); +#endif + if (n > 0 && n < 21) + _characters (str, static_cast<size_t> (n)); + else + _schema_error (schema_error::invalid_unsigned_long_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/unsigned-long.hxx b/libxsde/xsde/cxx/serializer/validating/unsigned-long.hxx new file mode 100644 index 0000000..2659ef1 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/unsigned-long.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/validating/unsigned-long.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_VALIDATING_UNSIGNED_LONG_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_UNSIGNED_LONG_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + // Fall-back implementation when 64 bit long long is not available. + // +#ifdef XSDE_REUSE_STYLE_MIXIN + struct unsigned_long_simpl: virtual unsigned_long_sskel +#else + struct unsigned_long_simpl: unsigned_long_sskel +#endif + { + virtual void + pre (unsigned long); + + virtual void + _serialize_content (); + + protected: + unsigned long value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_UNSIGNED_LONG_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/unsigned-short.cxx b/libxsde/xsde/cxx/serializer/validating/unsigned-short.cxx new file mode 100644 index 0000000..d9bb308 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/unsigned-short.cxx @@ -0,0 +1,45 @@ +// file : xsde/cxx/serializer/validating/unsigned-short.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/validating/unsigned-short.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void unsigned_short_simpl:: + pre (unsigned short value) + { + value_ = value; + } + + void unsigned_short_simpl:: + _serialize_content () + { + // We only need strlen("65535") + 1 characters to hold all + // representations of short. + // + char str[6]; + +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 6, "%u", value_); +#else + int n = sprintf (str, "%u", value_); +#endif + if (n > 0 && n < 6) + _characters (str, static_cast<size_t> (n)); + else + _schema_error (schema_error::invalid_unsigned_short_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/unsigned-short.hxx b/libxsde/xsde/cxx/serializer/validating/unsigned-short.hxx new file mode 100644 index 0000000..902d75e --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/unsigned-short.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/validating/unsigned-short.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_VALIDATING_UNSIGNED_SHORT_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_UNSIGNED_SHORT_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + // 16-bit unsigned integer + // +#ifdef XSDE_REUSE_STYLE_MIXIN + struct unsigned_short_simpl: virtual unsigned_short_sskel +#else + struct unsigned_short_simpl: unsigned_short_sskel +#endif + { + virtual void + pre (unsigned short); + + virtual void + _serialize_content (); + + protected: + unsigned short value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_UNSIGNED_SHORT_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/uri-stl.cxx b/libxsde/xsde/cxx/serializer/validating/uri-stl.cxx new file mode 100644 index 0000000..d22c992 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/uri-stl.cxx @@ -0,0 +1,39 @@ +// file : xsde/cxx/serializer/validating/uri-stl.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/serializer/validating/uri-stl.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void uri_simpl:: + pre (const std::string& value) + { + value_ = value; + } + + void uri_simpl:: + _serialize_content () + { + // Make sure we don't hold any references to the string. + // + std::string tmp; + tmp.swap (value_); + + // According to Datatypes 3.2.17 and RFC2396 pretty much anything + // can be a URI and conforming processors do not need to figure + // out and verify particular URI schemes. + // + _characters (tmp.c_str (), tmp.size ()); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/uri-stl.hxx b/libxsde/xsde/cxx/serializer/validating/uri-stl.hxx new file mode 100644 index 0000000..4de5922 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/uri-stl.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/validating/uri-stl.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_VALIDATING_URI_STL_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_URI_STL_HXX + +#include <string> + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct uri_simpl: virtual uri_sskel +#else + struct uri_simpl: uri_sskel +#endif + { + virtual void + pre (const std::string&); + + virtual void + _serialize_content (); + + protected: + std::string value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_URI_STL_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/uri.cxx b/libxsde/xsde/cxx/serializer/validating/uri.cxx new file mode 100644 index 0000000..46148d3 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/uri.cxx @@ -0,0 +1,47 @@ +// file : xsde/cxx/serializer/validating/uri.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/serializer/validating/uri.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + uri_simpl:: + ~uri_simpl () + { + if (free_) + delete[] const_cast<char*> (value_); + } + + void uri_simpl:: + pre (const char* value) + { + value_ = value; + } + + void uri_simpl:: + _serialize_content () + { + // According to Datatypes 3.2.17 and RFC2396 pretty much anything + // can be a URI and conforming processors do not need to figure + // out and verify particular URI schemes. + // + _characters (value_); + + if (free_) + { + delete[] const_cast<char*> (value_); + value_ = 0; + } + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/uri.hxx b/libxsde/xsde/cxx/serializer/validating/uri.hxx new file mode 100644 index 0000000..63b502a --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/uri.hxx @@ -0,0 +1,47 @@ +// file : xsde/cxx/serializer/validating/uri.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_VALIDATING_URI_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_URI_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct uri_simpl: virtual uri_sskel +#else + struct uri_simpl: uri_sskel +#endif + { + virtual + ~uri_simpl (); + + uri_simpl (bool free = false); + + virtual void + pre (const char*); + + virtual void + _serialize_content (); + + protected: + bool free_; + const char* value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/uri.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_URI_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/uri.ixx b/libxsde/xsde/cxx/serializer/validating/uri.ixx new file mode 100644 index 0000000..6cbf6ae --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/uri.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/validating/uri.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + inline uri_simpl:: + uri_simpl (bool free) + : free_ (free), value_ (0) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/xml-schema-simpl.hxx b/libxsde/xsde/cxx/serializer/validating/xml-schema-simpl.hxx new file mode 100644 index 0000000..039722f --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/xml-schema-simpl.hxx @@ -0,0 +1,82 @@ +// file : xsde/cxx/serializer/validating/xml-schema-simpl.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_VALIDATING_XML_SCHEMA_SIMPL_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_XML_SCHEMA_SIMPL_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +#include <xsde/cxx/serializer/validating/any-type.hxx> +#include <xsde/cxx/serializer/validating/boolean.hxx> +#include <xsde/cxx/serializer/validating/byte.hxx> +#include <xsde/cxx/serializer/validating/unsigned-byte.hxx> +#include <xsde/cxx/serializer/validating/byte.hxx> +#include <xsde/cxx/serializer/validating/unsigned-byte.hxx> +#include <xsde/cxx/serializer/validating/short.hxx> +#include <xsde/cxx/serializer/validating/unsigned-short.hxx> +#include <xsde/cxx/serializer/validating/int.hxx> +#include <xsde/cxx/serializer/validating/unsigned-int.hxx> + +#ifdef XSDE_LONGLONG +# include <xsde/cxx/serializer/validating/long-long.hxx> +# include <xsde/cxx/serializer/validating/unsigned-long-long.hxx> +#else +# include <xsde/cxx/serializer/validating/long.hxx> +# include <xsde/cxx/serializer/validating/unsigned-long.hxx> +#endif + +#include <xsde/cxx/serializer/validating/integer.hxx> +#include <xsde/cxx/serializer/validating/negative-integer.hxx> +#include <xsde/cxx/serializer/validating/non-positive-integer.hxx> +#include <xsde/cxx/serializer/validating/positive-integer.hxx> +#include <xsde/cxx/serializer/validating/non-negative-integer.hxx> +#include <xsde/cxx/serializer/validating/float.hxx> +#include <xsde/cxx/serializer/validating/double.hxx> +#include <xsde/cxx/serializer/validating/decimal.hxx> + +#ifdef XSDE_STL +# include <xsde/cxx/serializer/validating/string-stl.hxx> +# include <xsde/cxx/serializer/validating/normalized-string-stl.hxx> +# include <xsde/cxx/serializer/validating/token-stl.hxx> +# include <xsde/cxx/serializer/validating/name-stl.hxx> +# include <xsde/cxx/serializer/validating/nmtoken-stl.hxx> +# include <xsde/cxx/serializer/validating/nmtokens-stl.hxx> +# include <xsde/cxx/serializer/validating/ncname-stl.hxx> +# include <xsde/cxx/serializer/validating/id-stl.hxx> +# include <xsde/cxx/serializer/validating/idref-stl.hxx> +# include <xsde/cxx/serializer/validating/idrefs-stl.hxx> +# include <xsde/cxx/serializer/validating/language-stl.hxx> +# include <xsde/cxx/serializer/validating/uri-stl.hxx> +# include <xsde/cxx/serializer/validating/qname-stl.hxx> +#else +# include <xsde/cxx/serializer/validating/string.hxx> +# include <xsde/cxx/serializer/validating/normalized-string.hxx> +# include <xsde/cxx/serializer/validating/token.hxx> +# include <xsde/cxx/serializer/validating/name.hxx> +# include <xsde/cxx/serializer/validating/nmtoken.hxx> +# include <xsde/cxx/serializer/validating/nmtokens.hxx> +# include <xsde/cxx/serializer/validating/ncname.hxx> +# include <xsde/cxx/serializer/validating/id.hxx> +# include <xsde/cxx/serializer/validating/idref.hxx> +# include <xsde/cxx/serializer/validating/idrefs.hxx> +# include <xsde/cxx/serializer/validating/language.hxx> +# include <xsde/cxx/serializer/validating/uri.hxx> +# include <xsde/cxx/serializer/validating/qname.hxx> +#endif + +#include <xsde/cxx/serializer/validating/base64-binary.hxx> +#include <xsde/cxx/serializer/validating/hex-binary.hxx> + +#include <xsde/cxx/serializer/validating/gday.hxx> +#include <xsde/cxx/serializer/validating/gmonth.hxx> +#include <xsde/cxx/serializer/validating/gyear.hxx> +#include <xsde/cxx/serializer/validating/gmonth-day.hxx> +#include <xsde/cxx/serializer/validating/gyear-month.hxx> +#include <xsde/cxx/serializer/validating/date.hxx> +#include <xsde/cxx/serializer/validating/time.hxx> +#include <xsde/cxx/serializer/validating/date-time.hxx> +#include <xsde/cxx/serializer/validating/duration.hxx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_XML_SCHEMA_SIMPL_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/xml-schema-sskel.cxx b/libxsde/xsde/cxx/serializer/validating/xml-schema-sskel.cxx new file mode 100644 index 0000000..a18141b --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/xml-schema-sskel.cxx @@ -0,0 +1,560 @@ +// file : xsde/cxx/serializer/validating/xml-schema-sskel.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + // any_type_sskel + // + void any_type_sskel:: + pre () + { +#ifdef XSDE_REUSE_STYLE_TIEIN + if (any_type_impl_) + any_type_impl_->pre (); +#endif + } + + // any_simple_type_sskel + // + void any_simple_type_sskel:: + pre () + { +#ifdef XSDE_REUSE_STYLE_TIEIN + if (any_simple_type_impl_) + any_simple_type_impl_->pre (); +#endif + } + + // static/dynamic_type function implementations. + // +#ifdef XSDE_POLYMORPHIC + const char* any_type_sskel:: + _static_type () + { + return "anyType http://www.w3.org/2001/XMLSchema"; + } + + const char* any_type_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* any_simple_type_sskel:: + _static_type () + { + return "anySimpleType http://www.w3.org/2001/XMLSchema"; + } + + const char* any_simple_type_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* boolean_sskel:: + _static_type () + { + return "boolean http://www.w3.org/2001/XMLSchema"; + } + + const char* boolean_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* byte_sskel:: + _static_type () + { + return "byte http://www.w3.org/2001/XMLSchema"; + } + + const char* byte_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* unsigned_byte_sskel:: + _static_type () + { + return "unsignedByte http://www.w3.org/2001/XMLSchema"; + } + + const char* unsigned_byte_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* short_sskel:: + _static_type () + { + return "short http://www.w3.org/2001/XMLSchema"; + } + + const char* short_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* unsigned_short_sskel:: + _static_type () + { + return "unsignedShort http://www.w3.org/2001/XMLSchema"; + } + + const char* unsigned_short_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* int_sskel:: + _static_type () + { + return "int http://www.w3.org/2001/XMLSchema"; + } + + const char* int_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* unsigned_int_sskel:: + _static_type () + { + return "unsignedInt http://www.w3.org/2001/XMLSchema"; + } + + const char* unsigned_int_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* long_sskel:: + _static_type () + { + return "long http://www.w3.org/2001/XMLSchema"; + } + + const char* long_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* unsigned_long_sskel:: + _static_type () + { + return "unsignedLong http://www.w3.org/2001/XMLSchema"; + } + + const char* unsigned_long_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* integer_sskel:: + _static_type () + { + return "integer http://www.w3.org/2001/XMLSchema"; + } + + const char* integer_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* negative_integer_sskel:: + _static_type () + { + return "negativeInteger http://www.w3.org/2001/XMLSchema"; + } + + const char* negative_integer_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* non_positive_integer_sskel:: + _static_type () + { + return "nonPositiveInteger http://www.w3.org/2001/XMLSchema"; + } + + const char* non_positive_integer_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* positive_integer_sskel:: + _static_type () + { + return "positiveInteger http://www.w3.org/2001/XMLSchema"; + } + + const char* positive_integer_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* non_negative_integer_sskel:: + _static_type () + { + return "nonNegativeInteger http://www.w3.org/2001/XMLSchema"; + } + + const char* non_negative_integer_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* float_sskel:: + _static_type () + { + return "float http://www.w3.org/2001/XMLSchema"; + } + + const char* float_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* double_sskel:: + _static_type () + { + return "double http://www.w3.org/2001/XMLSchema"; + } + + const char* double_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* decimal_sskel:: + _static_type () + { + return "decimal http://www.w3.org/2001/XMLSchema"; + } + + const char* decimal_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* string_sskel:: + _static_type () + { + return "string http://www.w3.org/2001/XMLSchema"; + } + + const char* string_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* normalized_string_sskel:: + _static_type () + { + return "normalizedString http://www.w3.org/2001/XMLSchema"; + } + + const char* normalized_string_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* token_sskel:: + _static_type () + { + return "token http://www.w3.org/2001/XMLSchema"; + } + + const char* token_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* name_sskel:: + _static_type () + { + return "Name http://www.w3.org/2001/XMLSchema"; + } + + const char* name_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* nmtoken_sskel:: + _static_type () + { + return "NMTOKEN http://www.w3.org/2001/XMLSchema"; + } + + const char* nmtoken_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* nmtokens_sskel:: + _static_type () + { + return "NMTOKENS http://www.w3.org/2001/XMLSchema"; + } + + const char* nmtokens_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* ncname_sskel:: + _static_type () + { + return "NCName http://www.w3.org/2001/XMLSchema"; + } + + const char* ncname_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* id_sskel:: + _static_type () + { + return "ID http://www.w3.org/2001/XMLSchema"; + } + + const char* id_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* idref_sskel:: + _static_type () + { + return "IDREF http://www.w3.org/2001/XMLSchema"; + } + + const char* idref_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* idrefs_sskel:: + _static_type () + { + return "IDREFS http://www.w3.org/2001/XMLSchema"; + } + + const char* idrefs_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* language_sskel:: + _static_type () + { + return "language http://www.w3.org/2001/XMLSchema"; + } + + const char* language_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* uri_sskel:: + _static_type () + { + return "anyURI http://www.w3.org/2001/XMLSchema"; + } + + const char* uri_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* qname_sskel:: + _static_type () + { + return "QName http://www.w3.org/2001/XMLSchema"; + } + + const char* qname_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* base64_binary_sskel:: + _static_type () + { + return "base64Binary http://www.w3.org/2001/XMLSchema"; + } + + const char* base64_binary_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* hex_binary_sskel:: + _static_type () + { + return "hexBinary http://www.w3.org/2001/XMLSchema"; + } + + const char* hex_binary_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* gday_sskel:: + _static_type () + { + return "gDay http://www.w3.org/2001/XMLSchema"; + } + + const char* gday_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* gmonth_sskel:: + _static_type () + { + return "gMonth http://www.w3.org/2001/XMLSchema"; + } + + const char* gmonth_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* gyear_sskel:: + _static_type () + { + return "gYear http://www.w3.org/2001/XMLSchema"; + } + + const char* gyear_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* gmonth_day_sskel:: + _static_type () + { + return "gMonthDay http://www.w3.org/2001/XMLSchema"; + } + + const char* gmonth_day_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* gyear_month_sskel:: + _static_type () + { + return "gYearMonth http://www.w3.org/2001/XMLSchema"; + } + + const char* gyear_month_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* date_sskel:: + _static_type () + { + return "date http://www.w3.org/2001/XMLSchema"; + } + + const char* date_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* time_sskel:: + _static_type () + { + return "time http://www.w3.org/2001/XMLSchema"; + } + + const char* time_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* date_time_sskel:: + _static_type () + { + return "dateTime http://www.w3.org/2001/XMLSchema"; + } + + const char* date_time_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* duration_sskel:: + _static_type () + { + return "duration http://www.w3.org/2001/XMLSchema"; + } + + const char* duration_sskel:: + _dynamic_type () const + { + return _static_type (); + } +#endif // XSDE_POLYMORPHIC + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/xml-schema-sskel.hxx b/libxsde/xsde/cxx/serializer/validating/xml-schema-sskel.hxx new file mode 100644 index 0000000..9a158b0 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/xml-schema-sskel.hxx @@ -0,0 +1,1382 @@ +// file : xsde/cxx/serializer/validating/xml-schema-sskel.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_VALIDATING_XML_SCHEMA_SSKEL_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_XML_SCHEMA_SSKEL_HXX + +#include <xsde/cxx/config.hxx> + +#ifdef XSDE_STL +# include <string> +#endif + +#include <xsde/cxx/serializer/xml-schema.hxx> + +#include <xsde/cxx/serializer/validating/serializer.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + // anyType and anySimpleType. + // + struct any_type_sskel: complex_content + { + virtual void + pre (); + + // Override the following two functions to implement + // your logic. + // + + // virtual void + // _serialize_attributes (); + + // virtual void + // _serialize_content (); + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + any_type_sskel (); + any_type_sskel (any_type_sskel* impl, void*); + + protected: + any_type_sskel* any_type_impl_; +#endif + }; + + struct any_simple_type_sskel: simple_content + { + virtual void + pre (); + + // Override the following function to implement your + // logic. + // + + // virtual void + // _serialize_content (); + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + any_simple_type_sskel (); + any_simple_type_sskel (any_simple_type_sskel* impl, void*); + + protected: + any_simple_type_sskel* any_simple_type_impl_; +#endif + }; + + // Boolean. + // + struct boolean_sskel: simple_content + { + virtual void + pre (bool) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + boolean_sskel (); + boolean_sskel (boolean_sskel* impl, void*); + + protected: + boolean_sskel* boolean_impl_; +#endif + }; + + // 8-bit + // + + struct byte_sskel: simple_content + { + virtual void + pre (signed char) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + byte_sskel (); + byte_sskel (byte_sskel* impl, void*); + + protected: + byte_sskel* byte_impl_; +#endif + }; + + struct unsigned_byte_sskel: simple_content + { + virtual void + pre (unsigned char) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + unsigned_byte_sskel (); + unsigned_byte_sskel (unsigned_byte_sskel* impl, void*); + + protected: + unsigned_byte_sskel* unsigned_byte_impl_; +#endif + }; + + + // 16-bit + // + + struct short_sskel: simple_content + { + virtual void + pre (short) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + short_sskel (); + short_sskel (short_sskel* impl, void*); + + protected: + short_sskel* short_impl_; +#endif + }; + + struct unsigned_short_sskel: simple_content + { + virtual void + pre (unsigned short) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + unsigned_short_sskel (); + unsigned_short_sskel (unsigned_short_sskel* impl, void*); + + protected: + unsigned_short_sskel* unsigned_short_impl_; +#endif + }; + + // 32-bit + // + + struct int_sskel: simple_content + { + virtual void + pre (int) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + int_sskel (); + int_sskel (int_sskel* impl, void*); + + protected: + int_sskel* int_impl_; +#endif + }; + + struct unsigned_int_sskel: simple_content + { + virtual void + pre (unsigned int) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + unsigned_int_sskel (); + unsigned_int_sskel (unsigned_int_sskel* impl, void*); + + protected: + unsigned_int_sskel* unsigned_int_impl_; +#endif + }; + + // 64-bit + // + +#ifdef XSDE_LONGLONG + struct long_sskel: simple_content + { + virtual void + pre (long long) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + long_sskel (); + long_sskel (long_sskel* impl, void*); + + protected: + long_sskel* long_impl_; +#endif + }; + + struct unsigned_long_sskel: simple_content + { + virtual void + pre (unsigned long long) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + unsigned_long_sskel (); + unsigned_long_sskel (unsigned_long_sskel* impl, void*); + + protected: + unsigned_long_sskel* unsigned_long_impl_; +#endif + }; +#else + struct long_sskel: simple_content + { + virtual void + pre (long) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + long_sskel (); + long_sskel (long_sskel* impl, void*); + + protected: + long_sskel* long_impl_; +#endif + }; + + struct unsigned_long_sskel: simple_content + { + virtual void + pre (unsigned long) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + unsigned_long_sskel (); + unsigned_long_sskel (unsigned_long_sskel* impl, void*); + + protected: + unsigned_long_sskel* unsigned_long_impl_; +#endif + }; +#endif + + // Arbitrary-length integers. + // + + struct integer_sskel: simple_content + { + virtual void + pre (long) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + integer_sskel (); + integer_sskel (integer_sskel* impl, void*); + + protected: + integer_sskel* integer_impl_; +#endif + }; + + struct negative_integer_sskel: simple_content + { + virtual void + pre (long) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + negative_integer_sskel (); + negative_integer_sskel (negative_integer_sskel* impl, void*); + + protected: + negative_integer_sskel* negative_integer_impl_; +#endif + }; + + struct non_positive_integer_sskel: simple_content + { + virtual void + pre (long) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + non_positive_integer_sskel (); + non_positive_integer_sskel (non_positive_integer_sskel* impl, void*); + + protected: + non_positive_integer_sskel* non_positive_integer_impl_; +#endif + }; + + struct positive_integer_sskel: simple_content + { + virtual void + pre (unsigned long) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + positive_integer_sskel (); + positive_integer_sskel (positive_integer_sskel* impl, void*); + + protected: + positive_integer_sskel* positive_integer_impl_; +#endif + }; + + struct non_negative_integer_sskel: simple_content + { + virtual void + pre (unsigned long) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + non_negative_integer_sskel (); + non_negative_integer_sskel (non_negative_integer_sskel* impl, void*); + + protected: + non_negative_integer_sskel* non_negative_integer_impl_; +#endif + }; + + // Floats. + // + + struct float_sskel: simple_content + { + virtual void + pre (float) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + float_sskel (); + float_sskel (float_sskel* impl, void*); + + protected: + float_sskel* float_impl_; +#endif + }; + + struct double_sskel: simple_content + { + virtual void + pre (double) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + double_sskel (); + double_sskel (double_sskel* impl, void*); + + protected: + double_sskel* double_impl_; +#endif + }; + + struct decimal_sskel: simple_content + { + virtual void + pre (double) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + decimal_sskel (); + decimal_sskel (decimal_sskel* impl, void*); + + protected: + decimal_sskel* decimal_impl_; +#endif + }; + + // String-based types. + // +#ifdef XSDE_STL + + struct string_sskel: simple_content + { + virtual void + pre (const std::string&) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + string_sskel (); + string_sskel (string_sskel* impl, void*); + + protected: + string_sskel* string_impl_; +#endif + }; + +#ifdef XSDE_REUSE_STYLE_MIXIN + struct normalized_string_sskel: virtual string_sskel +#else + struct normalized_string_sskel: string_sskel +#endif + { +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + normalized_string_sskel (); + normalized_string_sskel (normalized_string_sskel* impl, void*); + + protected: + normalized_string_sskel* normalized_string_impl_; +#endif + }; + +#ifdef XSDE_REUSE_STYLE_MIXIN + struct token_sskel: virtual normalized_string_sskel +#else + struct token_sskel: normalized_string_sskel +#endif + { +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + token_sskel (); + token_sskel (token_sskel* impl, void*); + + protected: + token_sskel* token_impl_; +#endif + }; + +#ifdef XSDE_REUSE_STYLE_MIXIN + struct name_sskel: virtual token_sskel +#else + struct name_sskel: token_sskel +#endif + { +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + name_sskel (); + name_sskel (name_sskel* impl, void*); + + protected: + name_sskel* name_impl_; +#endif + }; + +#ifdef XSDE_REUSE_STYLE_MIXIN + struct nmtoken_sskel: virtual token_sskel +#else + struct nmtoken_sskel: token_sskel +#endif + { +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + nmtoken_sskel (); + nmtoken_sskel (nmtoken_sskel* impl, void*); + + protected: + nmtoken_sskel* nmtoken_impl_; +#endif + }; + + struct nmtokens_sskel: simple_content + { + virtual void + pre (const string_sequence*) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + nmtokens_sskel (); + nmtokens_sskel (nmtokens_sskel* impl, void*); + + protected: + nmtokens_sskel* nmtokens_impl_; +#endif + }; + +#ifdef XSDE_REUSE_STYLE_MIXIN + struct ncname_sskel: virtual name_sskel +#else + struct ncname_sskel: name_sskel +#endif + { +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + ncname_sskel (); + ncname_sskel (ncname_sskel* impl, void*); + + protected: + ncname_sskel* ncname_impl_; +#endif + }; + +#ifdef XSDE_REUSE_STYLE_MIXIN + struct id_sskel: virtual ncname_sskel +#else + struct id_sskel: ncname_sskel +#endif + { +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + id_sskel (); + id_sskel (id_sskel* impl, void*); + + protected: + id_sskel* id_impl_; +#endif + }; + +#ifdef XSDE_REUSE_STYLE_MIXIN + struct idref_sskel: virtual ncname_sskel +#else + struct idref_sskel: ncname_sskel +#endif + { +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + idref_sskel (); + idref_sskel (idref_sskel* impl, void*); + + protected: + idref_sskel* idref_impl_; +#endif + }; + + struct idrefs_sskel: simple_content + { + virtual void + pre (const string_sequence*) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + idrefs_sskel (); + idrefs_sskel (idrefs_sskel* impl, void*); + + protected: + idrefs_sskel* idrefs_impl_; +#endif + }; + +#ifdef XSDE_REUSE_STYLE_MIXIN + struct language_sskel: virtual token_sskel +#else + struct language_sskel: token_sskel +#endif + { +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + language_sskel (); + language_sskel (language_sskel* impl, void*); + + protected: + language_sskel* language_impl_; +#endif + }; + + struct uri_sskel: simple_content + { + virtual void + pre (const std::string&) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + uri_sskel (); + uri_sskel (uri_sskel* impl, void*); + + protected: + uri_sskel* uri_impl_; +#endif + }; + + struct qname_sskel: simple_content + { + virtual void + pre (const qname&) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + qname_sskel (); + qname_sskel (qname_sskel* impl, void*); + + protected: + qname_sskel* qname_impl_; +#endif + }; + +#else // XSDE_STL + + struct string_sskel: simple_content + { + virtual void + pre (const char*) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + string_sskel (); + string_sskel (string_sskel* impl, void*); + + protected: + string_sskel* string_impl_; +#endif + }; + +#ifdef XSDE_REUSE_STYLE_MIXIN + struct normalized_string_sskel: virtual string_sskel +#else + struct normalized_string_sskel: string_sskel +#endif + { +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + normalized_string_sskel (); + normalized_string_sskel (normalized_string_sskel* impl, void*); + + protected: + normalized_string_sskel* normalized_string_impl_; +#endif + }; + +#ifdef XSDE_REUSE_STYLE_MIXIN + struct token_sskel: virtual normalized_string_sskel +#else + struct token_sskel: normalized_string_sskel +#endif + { +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + token_sskel (); + token_sskel (token_sskel* impl, void*); + + protected: + token_sskel* token_impl_; +#endif + }; + +#ifdef XSDE_REUSE_STYLE_MIXIN + struct name_sskel: virtual token_sskel +#else + struct name_sskel: token_sskel +#endif + { +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + name_sskel (); + name_sskel (name_sskel* impl, void*); + + protected: + name_sskel* name_impl_; +#endif + }; + +#ifdef XSDE_REUSE_STYLE_MIXIN + struct nmtoken_sskel: virtual token_sskel +#else + struct nmtoken_sskel: token_sskel +#endif + { +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + nmtoken_sskel (); + nmtoken_sskel (nmtoken_sskel* impl, void*); + + protected: + nmtoken_sskel* nmtoken_impl_; +#endif + }; + + struct nmtokens_sskel: simple_content + { + virtual void + pre (const string_sequence*) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + nmtokens_sskel (); + nmtokens_sskel (nmtokens_sskel* impl, void*); + + protected: + nmtokens_sskel* nmtokens_impl_; +#endif + }; + +#ifdef XSDE_REUSE_STYLE_MIXIN + struct ncname_sskel: virtual name_sskel +#else + struct ncname_sskel: name_sskel +#endif + { +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + ncname_sskel (); + ncname_sskel (ncname_sskel* impl, void*); + + protected: + ncname_sskel* ncname_impl_; +#endif + }; + +#ifdef XSDE_REUSE_STYLE_MIXIN + struct id_sskel: virtual ncname_sskel +#else + struct id_sskel: ncname_sskel +#endif + { +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + id_sskel (); + id_sskel (id_sskel* impl, void*); + + protected: + id_sskel* id_impl_; +#endif + }; + +#ifdef XSDE_REUSE_STYLE_MIXIN + struct idref_sskel: virtual ncname_sskel +#else + struct idref_sskel: ncname_sskel +#endif + { +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + idref_sskel (); + idref_sskel (idref_sskel* impl, void*); + + protected: + idref_sskel* idref_impl_; +#endif + }; + + struct idrefs_sskel: simple_content + { + virtual void + pre (const string_sequence*) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + idrefs_sskel (); + idrefs_sskel (idrefs_sskel* impl, void*); + + protected: + idrefs_sskel* idrefs_impl_; +#endif + }; + +#ifdef XSDE_REUSE_STYLE_MIXIN + struct language_sskel: virtual token_sskel +#else + struct language_sskel: token_sskel +#endif + { +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + language_sskel (); + language_sskel (language_sskel* impl, void*); + + protected: + language_sskel* language_impl_; +#endif + }; + + struct uri_sskel: simple_content + { + virtual void + pre (const char*) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + uri_sskel (); + uri_sskel (uri_sskel* impl, void*); + + protected: + uri_sskel* uri_impl_; +#endif + }; + + struct qname_sskel: simple_content + { + virtual void + pre (const qname*) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + qname_sskel (); + qname_sskel (qname_sskel* impl, void*); + + protected: + qname_sskel* qname_impl_; +#endif + }; + +#endif // XSDE_STL + + + // base64Binary + // + struct base64_binary_sskel: simple_content + { + virtual void + pre (const buffer*) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + base64_binary_sskel (); + base64_binary_sskel (base64_binary_sskel* impl, void*); + + protected: + base64_binary_sskel* base64_binary_impl_; +#endif + }; + + // hexBinary + // + struct hex_binary_sskel: simple_content + { + virtual void + pre (const buffer*) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + hex_binary_sskel (); + hex_binary_sskel (hex_binary_sskel* impl, void*); + + protected: + hex_binary_sskel* hex_binary_impl_; +#endif + }; + + // Time and date types. + // + struct gday_sskel: simple_content + { + virtual void + pre (const gday&) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + gday_sskel (); + gday_sskel (gday_sskel* impl, void*); + + protected: + gday_sskel* gday_impl_; +#endif + }; + + struct gmonth_sskel: simple_content + { + virtual void + pre (const gmonth&) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + gmonth_sskel (); + gmonth_sskel (gmonth_sskel* impl, void*); + + protected: + gmonth_sskel* gmonth_impl_; +#endif + }; + + struct gyear_sskel: simple_content + { + virtual void + pre (const gyear&) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + gyear_sskel (); + gyear_sskel (gyear_sskel* impl, void*); + + protected: + gyear_sskel* gyear_impl_; +#endif + }; + + struct gmonth_day_sskel: simple_content + { + virtual void + pre (const gmonth_day&) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + gmonth_day_sskel (); + gmonth_day_sskel (gmonth_day_sskel* impl, void*); + + protected: + gmonth_day_sskel* gmonth_day_impl_; +#endif + }; + + struct gyear_month_sskel: simple_content + { + virtual void + pre (const gyear_month&) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + gyear_month_sskel (); + gyear_month_sskel (gyear_month_sskel* impl, void*); + + protected: + gyear_month_sskel* gyear_month_impl_; +#endif + }; + + struct date_sskel: simple_content + { + virtual void + pre (const date&) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + date_sskel (); + date_sskel (date_sskel* impl, void*); + + protected: + date_sskel* date_impl_; +#endif + }; + + struct time_sskel: simple_content + { + virtual void + pre (const time&) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + time_sskel (); + time_sskel (time_sskel* impl, void*); + + protected: + time_sskel* time_impl_; +#endif + }; + + struct date_time_sskel: simple_content + { + virtual void + pre (const date_time&) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + date_time_sskel (); + date_time_sskel (date_time_sskel* impl, void*); + + protected: + date_time_sskel* date_time_impl_; +#endif + }; + + struct duration_sskel: simple_content + { + virtual void + pre (const duration&) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + duration_sskel (); + duration_sskel (duration_sskel* impl, void*); + + protected: + duration_sskel* duration_impl_; +#endif + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_XML_SCHEMA_SSKEL_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/xml-schema-sskel.ixx b/libxsde/xsde/cxx/serializer/validating/xml-schema-sskel.ixx new file mode 100644 index 0000000..23647b5 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/xml-schema-sskel.ixx @@ -0,0 +1,704 @@ +// file : xsde/cxx/serializer/validating/xml-schema-sskel.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + // any_type_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline any_type_sskel:: + any_type_sskel () + : any_type_impl_ (0) + { + } + + inline any_type_sskel:: + any_type_sskel (any_type_sskel* impl, void*) + : complex_content (impl, 0), any_type_impl_ (impl) + { + } +#endif + + // any_simple_type_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline any_simple_type_sskel:: + any_simple_type_sskel () + : any_simple_type_impl_ (0) + { + } + + inline any_simple_type_sskel:: + any_simple_type_sskel (any_simple_type_sskel* impl, void*) + : simple_content (impl, 0), any_simple_type_impl_ (impl) + { + } +#endif + + // boolean_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline boolean_sskel:: + boolean_sskel () + : boolean_impl_ (0) + { + } + + inline boolean_sskel:: + boolean_sskel (boolean_sskel* impl, void*) + : simple_content (impl, 0), boolean_impl_ (impl) + { + } +#endif + + // byte_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline byte_sskel:: + byte_sskel () + : byte_impl_ (0) + { + } + + inline byte_sskel:: + byte_sskel (byte_sskel* impl, void*) + : simple_content (impl, 0), byte_impl_ (impl) + { + } +#endif + + // unsigned_byte_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline unsigned_byte_sskel:: + unsigned_byte_sskel () + : unsigned_byte_impl_ (0) + { + } + + inline unsigned_byte_sskel:: + unsigned_byte_sskel (unsigned_byte_sskel* impl, void*) + : simple_content (impl, 0), unsigned_byte_impl_ (impl) + { + } +#endif + + // short_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline short_sskel:: + short_sskel () + : short_impl_ (0) + { + } + + inline short_sskel:: + short_sskel (short_sskel* impl, void*) + : simple_content (impl, 0), short_impl_ (impl) + { + } +#endif + + // unsigned_short_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline unsigned_short_sskel:: + unsigned_short_sskel () + : unsigned_short_impl_ (0) + { + } + + inline unsigned_short_sskel:: + unsigned_short_sskel (unsigned_short_sskel* impl, void*) + : simple_content (impl, 0), unsigned_short_impl_ (impl) + { + } +#endif + + // int_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline int_sskel:: + int_sskel () + : int_impl_ (0) + { + } + + inline int_sskel:: + int_sskel (int_sskel* impl, void*) + : simple_content (impl, 0), int_impl_ (impl) + { + } +#endif + + // unsigned_int_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline unsigned_int_sskel:: + unsigned_int_sskel () + : unsigned_int_impl_ (0) + { + } + + inline unsigned_int_sskel:: + unsigned_int_sskel (unsigned_int_sskel* impl, void*) + : simple_content (impl, 0), unsigned_int_impl_ (impl) + { + } +#endif + + // long_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline long_sskel:: + long_sskel () + : long_impl_ (0) + { + } + + inline long_sskel:: + long_sskel (long_sskel* impl, void*) + : simple_content (impl, 0), long_impl_ (impl) + { + } +#endif + + // unsigned_long_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline unsigned_long_sskel:: + unsigned_long_sskel () + : unsigned_long_impl_ (0) + { + } + + inline unsigned_long_sskel:: + unsigned_long_sskel (unsigned_long_sskel* impl, void*) + : simple_content (impl, 0), unsigned_long_impl_ (impl) + { + } +#endif + + // integer_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline integer_sskel:: + integer_sskel () + : integer_impl_ (0) + { + } + + inline integer_sskel:: + integer_sskel (integer_sskel* impl, void*) + : simple_content (impl, 0), integer_impl_ (impl) + { + } +#endif + + // negative_integer_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline negative_integer_sskel:: + negative_integer_sskel () + : negative_integer_impl_ (0) + { + } + + inline negative_integer_sskel:: + negative_integer_sskel (negative_integer_sskel* impl, void*) + : simple_content (impl, 0), negative_integer_impl_ (impl) + { + } +#endif + + // non_positive_integer_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline non_positive_integer_sskel:: + non_positive_integer_sskel () + : non_positive_integer_impl_ (0) + { + } + + inline non_positive_integer_sskel:: + non_positive_integer_sskel (non_positive_integer_sskel* impl, void*) + : simple_content (impl, 0), non_positive_integer_impl_ (impl) + { + } +#endif + + // positive_integer_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline positive_integer_sskel:: + positive_integer_sskel () + : positive_integer_impl_ (0) + { + } + + inline positive_integer_sskel:: + positive_integer_sskel (positive_integer_sskel* impl, void*) + : simple_content (impl, 0), positive_integer_impl_ (impl) + { + } +#endif + + // non_negative_integer_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline non_negative_integer_sskel:: + non_negative_integer_sskel () + : non_negative_integer_impl_ (0) + { + } + + inline non_negative_integer_sskel:: + non_negative_integer_sskel (non_negative_integer_sskel* impl, void*) + : simple_content (impl, 0), non_negative_integer_impl_ (impl) + { + } +#endif + + // float_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline float_sskel:: + float_sskel () + : float_impl_ (0) + { + } + + inline float_sskel:: + float_sskel (float_sskel* impl, void*) + : simple_content (impl, 0), float_impl_ (impl) + { + } +#endif + + // double_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline double_sskel:: + double_sskel () + : double_impl_ (0) + { + } + + inline double_sskel:: + double_sskel (double_sskel* impl, void*) + : simple_content (impl, 0), double_impl_ (impl) + { + } +#endif + + // decimal_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline decimal_sskel:: + decimal_sskel () + : decimal_impl_ (0) + { + } + + inline decimal_sskel:: + decimal_sskel (decimal_sskel* impl, void*) + : simple_content (impl, 0), decimal_impl_ (impl) + { + } +#endif + + // string_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline string_sskel:: + string_sskel () + : string_impl_ (0) + { + } + + inline string_sskel:: + string_sskel (string_sskel* impl, void*) + : simple_content (impl, 0), string_impl_ (impl) + { + } +#endif + + // normalized_string_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline normalized_string_sskel:: + normalized_string_sskel () + : normalized_string_impl_ (0) + { + } + + inline normalized_string_sskel:: + normalized_string_sskel (normalized_string_sskel* impl, void*) + : string_sskel (impl, 0), normalized_string_impl_ (impl) + { + } +#endif + + // token_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline token_sskel:: + token_sskel () + : token_impl_ (0) + { + } + + inline token_sskel:: + token_sskel (token_sskel* impl, void*) + : normalized_string_sskel (impl, 0), token_impl_ (impl) + { + } +#endif + + // name_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline name_sskel:: + name_sskel () + : name_impl_ (0) + { + } + + inline name_sskel:: + name_sskel (name_sskel* impl, void*) + : token_sskel (impl, 0), name_impl_ (impl) + { + } +#endif + + // nmtoken_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline nmtoken_sskel:: + nmtoken_sskel () + : nmtoken_impl_ (0) + { + } + + inline nmtoken_sskel:: + nmtoken_sskel (nmtoken_sskel* impl, void*) + : token_sskel (impl, 0), nmtoken_impl_ (impl) + { + } +#endif + + // nmtokens_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline nmtokens_sskel:: + nmtokens_sskel () + : nmtokens_impl_ (0) + { + } + + inline nmtokens_sskel:: + nmtokens_sskel (nmtokens_sskel* impl, void*) + : simple_content (impl, 0), nmtokens_impl_ (impl) + { + } +#endif + + // ncname_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline ncname_sskel:: + ncname_sskel () + : ncname_impl_ (0) + { + } + + inline ncname_sskel:: + ncname_sskel (ncname_sskel* impl, void*) + : name_sskel (impl, 0), ncname_impl_ (impl) + { + } +#endif + + // id_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline id_sskel:: + id_sskel () + : id_impl_ (0) + { + } + + inline id_sskel:: + id_sskel (id_sskel* impl, void*) + : ncname_sskel (impl, 0), id_impl_ (impl) + { + } +#endif + + // idref_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline idref_sskel:: + idref_sskel () + : idref_impl_ (0) + { + } + + inline idref_sskel:: + idref_sskel (idref_sskel* impl, void*) + : ncname_sskel (impl, 0), idref_impl_ (impl) + { + } +#endif + + // idrefs_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline idrefs_sskel:: + idrefs_sskel () + : idrefs_impl_ (0) + { + } + + inline idrefs_sskel:: + idrefs_sskel (idrefs_sskel* impl, void*) + : simple_content (impl, 0), idrefs_impl_ (impl) + { + } +#endif + + // language_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline language_sskel:: + language_sskel () + : language_impl_ (0) + { + } + + inline language_sskel:: + language_sskel (language_sskel* impl, void*) + : token_sskel (impl, 0), language_impl_ (impl) + { + } +#endif + + // uri_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline uri_sskel:: + uri_sskel () + : uri_impl_ (0) + { + } + + inline uri_sskel:: + uri_sskel (uri_sskel* impl, void*) + : simple_content (impl, 0), uri_impl_ (impl) + { + } +#endif + + // qname_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline qname_sskel:: + qname_sskel () + : qname_impl_ (0) + { + } + + inline qname_sskel:: + qname_sskel (qname_sskel* impl, void*) + : simple_content (impl, 0), qname_impl_ (impl) + { + } +#endif + + // base64_binary_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline base64_binary_sskel:: + base64_binary_sskel () + : base64_binary_impl_ (0) + { + } + + inline base64_binary_sskel:: + base64_binary_sskel (base64_binary_sskel* impl, void*) + : simple_content (impl, 0), base64_binary_impl_ (impl) + { + } +#endif + + // hex_binary_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline hex_binary_sskel:: + hex_binary_sskel () + : hex_binary_impl_ (0) + { + } + + inline hex_binary_sskel:: + hex_binary_sskel (hex_binary_sskel* impl, void*) + : simple_content (impl, 0), hex_binary_impl_ (impl) + { + } +#endif + + // gday_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline gday_sskel:: + gday_sskel () + : gday_impl_ (0) + { + } + + inline gday_sskel:: + gday_sskel (gday_sskel* impl, void*) + : simple_content (impl, 0), gday_impl_ (impl) + { + } +#endif + + // gmonth_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline gmonth_sskel:: + gmonth_sskel () + : gmonth_impl_ (0) + { + } + + inline gmonth_sskel:: + gmonth_sskel (gmonth_sskel* impl, void*) + : simple_content (impl, 0), gmonth_impl_ (impl) + { + } +#endif + + // gyear_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline gyear_sskel:: + gyear_sskel () + : gyear_impl_ (0) + { + } + + inline gyear_sskel:: + gyear_sskel (gyear_sskel* impl, void*) + : simple_content (impl, 0), gyear_impl_ (impl) + { + } +#endif + + // gmonth_day_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline gmonth_day_sskel:: + gmonth_day_sskel () + : gmonth_day_impl_ (0) + { + } + + inline gmonth_day_sskel:: + gmonth_day_sskel (gmonth_day_sskel* impl, void*) + : simple_content (impl, 0), gmonth_day_impl_ (impl) + { + } +#endif + + // gyear_month_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline gyear_month_sskel:: + gyear_month_sskel () + : gyear_month_impl_ (0) + { + } + + inline gyear_month_sskel:: + gyear_month_sskel (gyear_month_sskel* impl, void*) + : simple_content (impl, 0), gyear_month_impl_ (impl) + { + } +#endif + + // date_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline date_sskel:: + date_sskel () + : date_impl_ (0) + { + } + + inline date_sskel:: + date_sskel (date_sskel* impl, void*) + : simple_content (impl, 0), date_impl_ (impl) + { + } +#endif + + // time_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline time_sskel:: + time_sskel () + : time_impl_ (0) + { + } + + inline time_sskel:: + time_sskel (time_sskel* impl, void*) + : simple_content (impl, 0), time_impl_ (impl) + { + } +#endif + + // date_time_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline date_time_sskel:: + date_time_sskel () + : date_time_impl_ (0) + { + } + + inline date_time_sskel:: + date_time_sskel (date_time_sskel* impl, void*) + : simple_content (impl, 0), date_time_impl_ (impl) + { + } +#endif + + // duration_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline duration_sskel:: + duration_sskel () + : duration_impl_ (0) + { + } + + inline duration_sskel:: + duration_sskel (duration_sskel* impl, void*) + : simple_content (impl, 0), duration_impl_ (impl) + { + } +#endif + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/xml-schema.hxx b/libxsde/xsde/cxx/serializer/xml-schema.hxx new file mode 100644 index 0000000..5897914 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/xml-schema.hxx @@ -0,0 +1,20 @@ +// file : xsde/cxx/serializer/xml-schema.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_SERIALIZER_XML_SCHEMA_HXX +#define XSDE_CXX_SERIALIZER_XML_SCHEMA_HXX + +#include <xsde/cxx/buffer.hxx> +#include <xsde/cxx/date-time.hxx> + +#ifdef XSDE_STL +# include <xsde/cxx/qname-stl.hxx> +# include <xsde/cxx/string-sequence-stl.hxx> +#else +# include <xsde/cxx/qname.hxx> +# include <xsde/cxx/string-sequence.hxx> +#endif + +#endif // XSDE_CXX_SERIALIZER_XML_SCHEMA_HXX |