aboutsummaryrefslogtreecommitdiff
path: root/tests/cxx/hybrid/binary/custom
diff options
context:
space:
mode:
Diffstat (limited to 'tests/cxx/hybrid/binary/custom')
-rw-r--r--tests/cxx/hybrid/binary/custom/driver.cxx102
-rw-r--r--tests/cxx/hybrid/binary/custom/makefile128
-rw-r--r--tests/cxx/hybrid/binary/custom/output.xml2
-rw-r--r--tests/cxx/hybrid/binary/custom/test.xml93
-rw-r--r--tests/cxx/hybrid/binary/custom/test.xsd131
5 files changed, 456 insertions, 0 deletions
diff --git a/tests/cxx/hybrid/binary/custom/driver.cxx b/tests/cxx/hybrid/binary/custom/driver.cxx
new file mode 100644
index 0000000..400551a
--- /dev/null
+++ b/tests/cxx/hybrid/binary/custom/driver.cxx
@@ -0,0 +1,102 @@
+// file : tests/cxx/hybrid/binary/custom/driver.cxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+// Test RAW insertion and extraction.
+//
+
+#include <memory>
+#include <iostream>
+
+#include "orawstream.hxx"
+#include "irawstream.hxx"
+
+#include "test.hxx"
+#include "test-pimpl.hxx"
+#include "test-simpl.hxx"
+
+using std::cerr;
+using std::endl;
+
+using namespace test;
+
+int
+main (int argc, char* argv[])
+{
+ /*
+ try
+ {
+ */
+
+ if (argc != 2)
+ {
+ cerr << "usage: " << argv[0] << " test.xml" << endl;
+ return 1;
+ }
+
+ // Parse.
+ //
+ root_paggr root_p;
+
+ xml_schema::document_pimpl doc_p (
+ root_p.root_parser (),
+ root_p.root_namespace (),
+ root_p.root_name ());
+
+ root_p.pre ();
+ doc_p.parse (argv[1]);
+ std::auto_ptr<type> r (root_p.post ());
+
+ // Save the object model to a RAW stream.
+ //
+ xml_schema::buffer buf;
+ orawstream oraw (buf);
+ oraw << *r;
+
+ // Load the object model from a RAW stream.
+ //
+ irawstream iraw (buf);
+ std::auto_ptr<type> c (new type);
+ iraw >> *c;
+
+ // Serialize.
+ //
+ root_saggr root_s;
+
+ xml_schema::document_simpl doc_s (
+ root_s.root_serializer (),
+ root_s.root_namespace (),
+ root_s.root_name ());
+
+ doc_s.add_prefix ("t", "test");
+
+ root_s.pre (*c);
+ doc_s.serialize (std::cout);
+ root_s.post ();
+
+ /*
+ }
+ catch (const xml_schema::xdr_exception&)
+ {
+ cerr << "XDR operation filed" << endl;
+ return 1;
+ }
+ catch (const xml_schema::parser_exception& e)
+ {
+ cerr << argv[0] << ":" << e.line () << ":" << e.column () << ": "
+ << e.text () << endl;
+ return 1;
+ }
+ catch (const xml_schema::serializer_exception& e)
+ {
+ cerr << "error: " << e.text () << endl;
+ return 1;
+ }
+ catch (const std::ios_base::failure&)
+ {
+ cerr << argv[0] << ": unable to open or read/write failure" << endl;
+ return 1;
+ }
+ */
+}
diff --git a/tests/cxx/hybrid/binary/custom/makefile b/tests/cxx/hybrid/binary/custom/makefile
new file mode 100644
index 0000000..50fe420
--- /dev/null
+++ b/tests/cxx/hybrid/binary/custom/makefile
@@ -0,0 +1,128 @@
+# file : tests/cxx/hybrid/binary/custom/makefile
+# 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 $(dir $(lastword $(MAKEFILE_LIST)))../../../../../build/bootstrap.make
+
+xsd := test.xsd
+cxx := driver.cxx exceptions.cxx orawstream.cxx irawstream.cxx
+
+obj := $(addprefix $(out_base)/,\
+$(cxx:.cxx=.o) \
+$(xsd:.xsd=.o) \
+$(xsd:.xsd=-pskel.o) \
+$(xsd:.xsd=-pimpl.o) \
+$(xsd:.xsd=-sskel.o) \
+$(xsd:.xsd=-simpl.o))
+
+dep := $(obj:.o=.o.d)
+
+xsde.l := $(out_root)/libxsde/xsde/xsde.l
+xsde.l.cpp-options := $(out_root)/libxsde/xsde/xsde.l.cpp-options
+
+driver := $(out_base)/driver
+dist := $(out_base)/.dist
+dist-win := $(out_base)/.dist-win
+clean := $(out_base)/.clean
+
+# Build.
+#
+$(driver): $(obj) $(xsde.l)
+
+$(obj) $(dep): $(xsde.l.cpp-options)
+
+genf := $(xsd:.xsd=.hxx) $(xsd:.xsd=.cxx) \
+ $(xsd:.xsd=-pskel.hxx) $(xsd:.xsd=-pskel.cxx) \
+ $(xsd:.xsd=-pimpl.hxx) $(xsd:.xsd=-pimpl.cxx) \
+ $(xsd:.xsd=-sskel.hxx) $(xsd:.xsd=-sskel.cxx) \
+ $(xsd:.xsd=-simpl.hxx) $(xsd:.xsd=-simpl.cxx)
+
+gen := $(addprefix $(out_base)/,$(genf))
+
+$(gen): $(out_root)/xsde/xsde
+$(gen): xsde := $(out_root)/xsde/xsde
+$(gen): xsde_options += --generate-parser --generate-serializer \
+--generate-aggregate --extern-xml-schema xml-schema.xsd \
+--generate-insertion orawstream --hxx-prologue '\\\#include "orawstream.hxx"' \
+--generate-extraction irawstream --hxx-prologue '\\\#include "irawstream.hxx"'
+
+# Header files for XML Schema namespace.
+#
+$(out_base)/xml-schema%hxx \
+$(out_base)/xml-schema-pskel%hxx \
+$(out_base)/xml-schema-sskel%hxx: $(out_root)/xsde/xsde
+ $(call message,xsde $(src_base)/xml-schema.xsd,\
+$(out_root)/xsde/xsde cxx-hybrid --output-dir $(out_base) \
+--generate-xml-schema --generate-parser --generate-serializer xml-schema.xsd)
+
+genf += xml-schema.hxx xml-schema-pskel.hxx xml-schema-sskel.hxx
+
+$(call include-dep,$(dep))
+
+# Convenience alias for default target.
+#
+.PHONY: $(out_base)/
+$(out_base)/: $(driver)
+
+
+# Dist.
+#
+dist-common := $(out_base)/.dist-common
+
+.PHONY: $(dist) $(dist-win) $(dist-common)
+
+$(dist) $(dist-win) $(dist-common): path := $(subst $(src_root)/,,$(src_base))
+
+$(dist-common):
+ $(call install-data,$(src_base)/driver.cxx,$(dist_prefix)/$(path)/driver.cxx)
+ $(call install-data,$(src_base)/library.xsd,$(dist_prefix)/$(path)/library.xsd)
+ $(call install-data,$(src_base)/library.xml,$(dist_prefix)/$(path)/library.xml)
+
+$(dist): $(dist-common)
+ $(call install-data,$(src_base)/README,$(dist_prefix)/$(path)/README)
+
+$(dist-win): $(dist-common)
+ $(call install-data,$(src_base)/README,$(dist_prefix)/$(path)/README.txt)
+ $(call message,,unix2dos $(dist_prefix)/$(path)/README.txt)
+
+
+# Clean.
+#
+.PHONY: $(clean)
+
+$(clean): $(driver).o.clean \
+ $(addsuffix .cxx.clean,$(obj)) \
+ $(addsuffix .cxx.clean,$(dep)) \
+ $(addprefix $(out_base)/,$(xsd:.xsd=.cxx.xsd.clean))
+ $(call message,rm $$1,rm -f $$1,$(out_base)/xml-schema.hxx)
+ $(call message,rm $$1,rm -f $$1,$(out_base)/xml-schema-pskel.hxx)
+ $(call message,rm $$1,rm -f $$1,$(out_base)/xml-schema-sskel.hxx)
+
+
+# Generated .gitignore.
+#
+ifeq ($(out_base),$(src_base))
+$(gen): | $(out_base)/.gitignore
+$(driver): | $(out_base)/.gitignore
+
+$(out_base)/.gitignore: files := driver $(genf)
+$(clean): $(out_base)/.gitignore.clean
+
+$(call include,$(bld_root)/git/gitignore.make)
+endif
+
+
+# How to.
+#
+$(call include,$(bld_root)/cxx/o-e.make)
+$(call include,$(bld_root)/cxx/cxx-o.make)
+$(call include,$(bld_root)/cxx/cxx-d.make)
+$(call include,$(bld_root)/install.make)
+$(call include,$(scf_root)/xsde/hybrid/xsd-cxx.make)
+
+
+# Dependencies.
+#
+$(call import,$(src_root)/xsde/makefile)
+$(call import,$(src_root)/libxsde/xsde/makefile)
diff --git a/tests/cxx/hybrid/binary/custom/output.xml b/tests/cxx/hybrid/binary/custom/output.xml
new file mode 100644
index 0000000..a484661
--- /dev/null
+++ b/tests/cxx/hybrid/binary/custom/output.xml
@@ -0,0 +1,2 @@
+<t:root xmlns:t="test"><list>1 2 3</list><union>abc</union><enumeration>left</enumeration><complex x="1"><a>aaa</a></complex><complex x="1" y="2"><a>aaa</a><b>bbb</b><c>c</c><c>cc</c><c>ccc</c></complex><choice></choice><choice><a>123</a></choice><choice><b>ab</b><b>cd</b><b>ef</b></choice><choice><c>12.34</c><d>false</d></choice><byte>65</byte><unsigned_byte>66</unsigned_byte><short>-222</short><unsigned_short>57005</unsigned_short><int>-57005</int><unsigned_int>3735928559</unsigned_int><long>-2147483648</long><unsigned_long>2147483647</unsigned_long><integer>-2147483648</integer><non_positive_integer>-2147483648</non_positive_integer><non_negative_integer>2147483647</non_negative_integer><positive_integer>2147483647</positive_integer><negative_integer>-2147483648</negative_integer><boolean>true</boolean><float>1234.12</float><double>12345678.1234568</double><decimal>1234567812345678</decimal><string>string</string><normalized_string>normalized string</normalized_string><token>one two three</token><name>name</name><name_token>name-token</name_token><name_tokens>name tokens</name_tokens><ncname>ncname</ncname><language>en-us</language><qname>xsi:schemaLocation</qname><id>elements1</id><id>elements2</id><id_ref>elements1</id_ref><id_refs>elements1 elements2</id_refs><any_uri>http://www.codesynthesis.com</any_uri><base64_binary>YmFzZTY0IGJpbmFyeQ==
+</base64_binary><hex_binary>6865782052696E617279</hex_binary><date>2001-10-26+02:00</date><date_time>2001-10-26T21:32:52+02:00</date_time><duration>P1Y2M3DT5H20M30S</duration><day>---01+02:00</day><month>--11+02:00</month><month_day>--02-11+02:00</month_day><year>2001+02:00</year><year_month>2001-11+02:00</year_month><time>21:32:52+02:00</time></t:root> \ No newline at end of file
diff --git a/tests/cxx/hybrid/binary/custom/test.xml b/tests/cxx/hybrid/binary/custom/test.xml
new file mode 100644
index 0000000..acd75d2
--- /dev/null
+++ b/tests/cxx/hybrid/binary/custom/test.xml
@@ -0,0 +1,93 @@
+<t:root xmlns:t="test">
+
+ <list>1 2 3</list>
+
+ <union>abc</union>
+
+ <enumeration>left</enumeration>
+
+ <complex x="1">
+ <a>aaa</a>
+ </complex>
+ <complex x="1" y="2">
+ <a>aaa</a>
+ <b>bbb</b>
+ <c>c</c>
+ <c>cc</c>
+ <c>ccc</c>
+ </complex>
+
+ <choice/>
+ <choice><a>123</a></choice>
+ <choice><b>ab</b><b>cd</b><b>ef</b></choice>
+ <choice><c>12.34</c><d>false</d></choice>
+
+ <!-- integers -->
+ <byte>65</byte>
+ <unsigned_byte>66</unsigned_byte>
+ <short>-222</short>
+ <unsigned_short>57005</unsigned_short>
+ <int>-57005</int>
+ <unsigned_int>3735928559</unsigned_int>
+ <long>-2147483648</long>
+ <unsigned_long>2147483647</unsigned_long>
+ <integer>-2147483648</integer>
+ <non_positive_integer>-2147483648</non_positive_integer>
+ <non_negative_integer>2147483647</non_negative_integer>
+ <positive_integer>2147483647</positive_integer>
+ <negative_integer>-2147483648</negative_integer>
+
+
+ <!-- boolean -->
+ <boolean>true</boolean>
+
+
+ <!-- floats -->
+ <float>1234.1234</float>
+ <double>12345678.12345678</double>
+ <decimal>1234567812345678.1234567812345678</decimal>
+
+
+ <!-- strings -->
+ <string>string</string>
+ <normalized_string>normalized string</normalized_string>
+ <token>one two three</token>
+ <name>name</name>
+ <name_token>name-token</name_token>
+ <name_tokens>name tokens</name_tokens>
+ <ncname>ncname</ncname>
+ <language>en-us</language>
+
+ <!-- qualified name -->
+ <qname>xsi:schemaLocation</qname>
+
+
+ <!-- ID/IDREF -->
+ <id>elements1</id>
+ <id>elements2</id>
+ <id_ref>elements1</id_ref>
+ <id_refs>elements1 elements2</id_refs>
+
+
+ <!-- URI -->
+ <any_uri>http://www.codesynthesis.com</any_uri>
+
+
+ <!-- binary -->
+ <base64_binary>YmFzZTY0IGJpbmFyeQ==</base64_binary>
+ <hex_binary>6865782052696E617279</hex_binary>
+
+
+ <!-- date/time -->
+ <date>2001-10-26+02:00</date>
+ <date_time>2001-10-26T21:32:52+02:00</date_time>
+ <duration>P1Y2M3DT5H20M30S</duration>
+ <day>---01+02:00</day>
+ <month>--11+02:00</month>
+ <month_day>--11-02+02:00</month_day>
+ <year>2001+02:00</year>
+ <year_month>2001-11+02:00</year_month>
+ <time>21:32:52+02:00</time>
+
+
+</t:root>
diff --git a/tests/cxx/hybrid/binary/custom/test.xsd b/tests/cxx/hybrid/binary/custom/test.xsd
new file mode 100644
index 0000000..7a92c7e
--- /dev/null
+++ b/tests/cxx/hybrid/binary/custom/test.xsd
@@ -0,0 +1,131 @@
+<?xml version="1.0"?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:t="test"
+ targetNamespace="test">
+
+ <simpleType name="list">
+ <list itemType="int"/>
+ </simpleType>
+
+ <simpleType name="union">
+ <union memberTypes="int string"/>
+ </simpleType>
+
+ <simpleType name="enumeration">
+ <restriction base="string">
+ <enumeration value="top"/>
+ <enumeration value="left"/>
+ <enumeration value="bottom"/>
+ <enumeration value="right"/>
+ </restriction>
+ </simpleType>
+
+ <complexType name="base">
+ <sequence>
+ <element name="a" type="string"/>
+ </sequence>
+ <attribute name="x" type="int" use="required"/>
+ </complexType>
+
+ <complexType name="complex">
+ <complexContent>
+ <extension base="t:base">
+ <sequence>
+ <element name="b" type="string" minOccurs="0"/>
+ <element name="c" type="string" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="y" type="int"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="choice">
+ <choice>
+ <element name="a" type="int" minOccurs="0"/>
+ <element name="b" type="string" maxOccurs="unbounded"/>
+ <sequence>
+ <element name="c" type="double"/>
+ <element name="d" type="boolean"/>
+ </sequence>
+ </choice>
+ </complexType>
+
+ <complexType name="type">
+ <sequence>
+ <element name="list" type="t:list"/>
+ <element name="union" type="t:union"/>
+ <element name="enumeration" type="t:enumeration"/>
+ <element name="complex" type="t:complex" maxOccurs="unbounded"/>
+ <element name="choice" type="t:choice" maxOccurs="unbounded"/>
+
+ <!-- integers -->
+ <element name="byte" type="byte"/>
+ <element name="unsigned_byte" type="unsignedByte"/>
+ <element name="short" type="short"/>
+ <element name="unsigned_short" type="unsignedShort"/>
+ <element name="int" type="int"/>
+ <element name="unsigned_int" type="unsignedInt"/>
+ <element name="long" type="long"/>
+ <element name="unsigned_long" type="unsignedLong"/>
+ <element name="integer" type="integer"/>
+ <element name="non_positive_integer" type="nonPositiveInteger"/>
+ <element name="non_negative_integer" type="nonNegativeInteger"/>
+ <element name="positive_integer" type="positiveInteger"/>
+ <element name="negative_integer" type="negativeInteger"/>
+
+
+ <!-- boolean -->
+ <element name="boolean" type="boolean"/>
+
+
+ <!-- floats -->
+ <element name="float" type="float"/>
+ <element name="double" type="double"/>
+ <element name="decimal" type="decimal"/>
+
+
+ <!-- strings -->
+ <element name="string" type="string"/>
+ <element name="normalized_string" type="normalizedString"/>
+ <element name="token" type="token"/>
+ <element name="name" type="Name"/>
+ <element name="name_token" type="NMTOKEN"/>
+ <element name="name_tokens" type="NMTOKENS"/>
+ <element name="ncname" type="NCName"/>
+ <element name="language" type="language"/>
+
+ <!-- qualified name -->
+ <element name="qname" type="QName"/>
+
+
+ <!-- ID/IDREF -->
+ <element name="id" maxOccurs="2" type="ID"/>
+ <element name="id_ref" type="IDREF"/>
+ <element name="id_refs" type="IDREFS"/>
+
+
+ <!-- URI -->
+ <element name="any_uri" type="anyURI"/>
+
+
+ <!-- binary -->
+ <element name="base64_binary" type="base64Binary"/>
+ <element name="hex_binary" type="hexBinary"/>
+
+
+ <!-- date/time -->
+ <element name="date" type="date"/>
+ <element name="date_time" type="dateTime"/>
+ <element name="duration" type="duration"/>
+ <element name="day" type="gDay"/>
+ <element name="month" type="gMonth"/>
+ <element name="month_day" type="gMonthDay"/>
+ <element name="year" type="gYear"/>
+ <element name="year_month" type="gYearMonth"/>
+ <element name="time" type="time"/>
+ </sequence>
+ </complexType>
+
+ <element name="root" type="t:type"/>
+
+</schema>