diff options
Diffstat (limited to 'xsd-tests/cxx/parser/enumeration')
-rw-r--r-- | xsd-tests/cxx/parser/enumeration/buildfile | 24 | ||||
-rw-r--r-- | xsd-tests/cxx/parser/enumeration/driver.cxx | 81 | ||||
-rw-r--r-- | xsd-tests/cxx/parser/enumeration/gender.hxx | 13 | ||||
-rw-r--r-- | xsd-tests/cxx/parser/enumeration/output | 3 | ||||
-rw-r--r-- | xsd-tests/cxx/parser/enumeration/test.map | 7 | ||||
-rw-r--r-- | xsd-tests/cxx/parser/enumeration/test.xml | 10 | ||||
-rw-r--r-- | xsd-tests/cxx/parser/enumeration/test.xsd | 35 |
7 files changed, 173 insertions, 0 deletions
diff --git a/xsd-tests/cxx/parser/enumeration/buildfile b/xsd-tests/cxx/parser/enumeration/buildfile new file mode 100644 index 0000000..05163df --- /dev/null +++ b/xsd-tests/cxx/parser/enumeration/buildfile @@ -0,0 +1,24 @@ +# file : cxx/parser/enumeration/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test-pskel} {hxx ixx cxx}{test-pskel} $libs + +exe{driver}: xml{test}: test.input = true +exe{driver}: file{output}: test.stdout = true + +<{hxx ixx cxx}{test-pskel}>: xsd{test} map{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-parser --std c++11 \ + --generate-inline \ + --skel-file-suffix -pskel \ + --output-dir $out_base \ + --type-map $path($<[1]) \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" "-I$src_base" diff --git a/xsd-tests/cxx/parser/enumeration/driver.cxx b/xsd-tests/cxx/parser/enumeration/driver.cxx new file mode 100644 index 0000000..4776ee2 --- /dev/null +++ b/xsd-tests/cxx/parser/enumeration/driver.cxx @@ -0,0 +1,81 @@ +// file : cxx/parser/enumeration/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test xsd:enumeration parsing. +// + +#include <string> +#include <iostream> + +#include "test-pskel.hxx" + +using namespace std; +using namespace xml_schema; + +struct digit_pimpl: test::digit_pskel, int_pimpl +{ +}; + +struct gender_pimpl: test::gender_pskel, string_pimpl +{ + virtual ::gender + post_gender () + { + std::string str (post_string ()); + + if (str == "male") + return male; + else + return female; + } +}; + +struct type_pimpl: test::type_pskel +{ + virtual void + digit (int i) + { + cout << i << endl; + } + + virtual void + gender (::gender g) + { + cout << g << endl; + } +}; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + try + { + digit_pimpl digit_p; + gender_pimpl gender_p; + type_pimpl type_p; + + type_p.parsers (digit_p, gender_p); + + document doc_p (type_p, "test", "root"); + + type_p.pre (); + doc_p.parse (argv[1]); + type_p.post_type (); + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } + catch (std::ios_base::failure const&) + { + cerr << "io failure" << endl; + return 1; + } +} diff --git a/xsd-tests/cxx/parser/enumeration/gender.hxx b/xsd-tests/cxx/parser/enumeration/gender.hxx new file mode 100644 index 0000000..a2e5cd8 --- /dev/null +++ b/xsd-tests/cxx/parser/enumeration/gender.hxx @@ -0,0 +1,13 @@ +// file : tests/cxx/parser/enumeration/gender.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef GENDER_HXX +#define GENDER_HXX + +enum gender +{ + male, + female +}; + +#endif // GENDER_HXX diff --git a/xsd-tests/cxx/parser/enumeration/output b/xsd-tests/cxx/parser/enumeration/output new file mode 100644 index 0000000..16db301 --- /dev/null +++ b/xsd-tests/cxx/parser/enumeration/output @@ -0,0 +1,3 @@ +1 +0 +1 diff --git a/xsd-tests/cxx/parser/enumeration/test.map b/xsd-tests/cxx/parser/enumeration/test.map new file mode 100644 index 0000000..f8868d6 --- /dev/null +++ b/xsd-tests/cxx/parser/enumeration/test.map @@ -0,0 +1,7 @@ +namespace test +{ + include "gender.hxx"; + + digit int int; + gender ::gender ::gender; +} diff --git a/xsd-tests/cxx/parser/enumeration/test.xml b/xsd-tests/cxx/parser/enumeration/test.xml new file mode 100644 index 0000000..a6fa893 --- /dev/null +++ b/xsd-tests/cxx/parser/enumeration/test.xml @@ -0,0 +1,10 @@ +<t:root xmlns:t="test" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="test test.xsd"> + + <digit>1</digit> + + <gender>male</gender> + <gender>female</gender> + +</t:root> diff --git a/xsd-tests/cxx/parser/enumeration/test.xsd b/xsd-tests/cxx/parser/enumeration/test.xsd new file mode 100644 index 0000000..ded3a18 --- /dev/null +++ b/xsd-tests/cxx/parser/enumeration/test.xsd @@ -0,0 +1,35 @@ +<?xml version="1.0"?> +<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:t="test" targetNamespace="test"> + + <simpleType name="digit"> + <restriction base="int"> + <enumeration value="0"/> + <enumeration value="1"/> + <enumeration value="2"/> + <enumeration value="3"/> + <enumeration value="4"/> + <enumeration value="5"/> + <enumeration value="6"/> + <enumeration value="7"/> + <enumeration value="8"/> + <enumeration value="9"/> + </restriction> + </simpleType> + + <simpleType name="gender"> + <restriction base="string"> + <enumeration value="male"/> + <enumeration value="female"/> + </restriction> + </simpleType> + + <complexType name="type"> + <choice maxOccurs="unbounded"> + <element name="digit" type="t:digit"/> + <element name="gender" type="t:gender"/> + </choice> + </complexType> + + <element name="root" type="t:type"/> + +</schema> |