diff options
author | Jörg Frings-Fürst <jff@merkur> | 2014-05-18 16:08:14 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <jff@merkur> | 2014-05-18 16:08:14 +0200 |
commit | a15cf65c44d5c224169c32ef5495b68c758134b7 (patch) | |
tree | 3419f58fc8e1b315ba8171910ee044c5d467c162 /xsd/tests/cxx/parser/recursive |
Imported Upstream version 3.3.0.2upstream/3.3.0.2
Diffstat (limited to 'xsd/tests/cxx/parser/recursive')
-rw-r--r-- | xsd/tests/cxx/parser/recursive/driver.cxx | 141 | ||||
-rw-r--r-- | xsd/tests/cxx/parser/recursive/makefile | 80 | ||||
-rw-r--r-- | xsd/tests/cxx/parser/recursive/output | 22 | ||||
-rw-r--r-- | xsd/tests/cxx/parser/recursive/test.xml | 11 | ||||
-rw-r--r-- | xsd/tests/cxx/parser/recursive/test.xsd | 27 |
5 files changed, 281 insertions, 0 deletions
diff --git a/xsd/tests/cxx/parser/recursive/driver.cxx b/xsd/tests/cxx/parser/recursive/driver.cxx new file mode 100644 index 0000000..3f54f8f --- /dev/null +++ b/xsd/tests/cxx/parser/recursive/driver.cxx @@ -0,0 +1,141 @@ +// file : tests/cxx/parser/recursive/driver.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2006-2010 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test recursive parser invocation. +// + +#include <iostream> +#include <string> + +#include "test-pskel.hxx" + +using namespace std; + +struct sub_pimpl: sub_type_pskel +{ + virtual void + pre () + { + cout << "sub::pre" << endl; + } + + virtual void + sub () + { + cout << "sub::sub" << endl; + } + + virtual void + sub2 () + { + cout << "sub::sub2" << endl; + } + + virtual void + name (string const& n) + { + cout << "sub::name: " << n << endl; + } + + virtual void + post_sub_type () + { + cout << "sub::post" << endl; + } +}; + +struct indir_pimpl: indir_type_pskel +{ + virtual void + pre () + { + cout << "indir::pre" << endl; + } + + virtual void + sub () + { + cout << "indir::sub" << endl; + } + + virtual void + name (string const& n) + { + cout << "indir::name: " << n << endl; + } + + virtual void + post_indir_type () + { + cout << "indir::post" << endl; + } +}; + +struct test_pimpl: test_type_pskel +{ + virtual void + pre () + { + cout << "test::pre" << endl; + } + + virtual void + sub () + { + cout << "test::sub" << endl; + } + + virtual void + name (string const& n) + { + cout << "test::name: " << n << endl; + } + + virtual void + post_test_type () + { + cout << "test::post" << endl; + } +}; + + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + try + { + xml_schema::string_pimpl string_p; + + sub_pimpl sub_p; + indir_pimpl indir_p; + test_pimpl test_p; + + sub_p.parsers (sub_p, indir_p, sub_p, string_p); + indir_p.parsers (sub_p, string_p); + test_p.parsers (sub_p, string_p); + + xml_schema::document doc_p (test_p, "test"); + + test_p.pre (); + doc_p.parse (argv[1]); + test_p.post_test_type (); + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } + catch (ios_base::failure const&) + { + cerr << "io failure" << endl; + return 1; + } +} diff --git a/xsd/tests/cxx/parser/recursive/makefile b/xsd/tests/cxx/parser/recursive/makefile new file mode 100644 index 0000000..bd78bef --- /dev/null +++ b/xsd/tests/cxx/parser/recursive/makefile @@ -0,0 +1,80 @@ +# file : tests/cxx/parser/recursive/makefile +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2006-2010 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 + +obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=-pskel.o)) +dep := $(obj:.o=.o.d) + +driver := $(out_base)/driver +test := $(out_base)/.test +clean := $(out_base)/.clean + +# Import. +# +$(call import,\ + $(scf_root)/import/libxerces-c/stub.make,\ + l: xerces_c.l,cpp-options: xerces_c.l.cpp-options) + +# Build. +# +$(driver): $(obj) $(xerces_c.l) + +$(obj) $(dep): cpp_options := -I$(src_root)/libxsd +$(obj) $(dep): $(xerces_c.l.cpp-options) + +genf := $(xsd:.xsd=-pskel.hxx) $(xsd:.xsd=-pskel.ixx) $(xsd:.xsd=-pskel.cxx) +gen := $(addprefix $(out_base)/,$(genf)) + +$(gen): xsd := $(out_root)/xsd/xsd +$(gen): xsd_options := --generate-validation +$(gen): $(out_root)/xsd/xsd + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +$(out_base)/: $(driver) + + +# Test. +# +$(test): driver := $(driver) +$(test): $(driver) $(src_base)/test.xml $(src_base)/output + $(call message,test $$1,$$1 $(src_base)/test.xml | diff -u $(src_base)/output -,$(driver)) + +# Clean. +# +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) \ + $(addprefix $(out_base)/,$(xsd:.xsd=-pskel.cxx.xsd.clean)) + +# 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,$(scf_root)/xsd/parser/xsd-cxx.make) + + +# Dependencies. +# +$(call import,$(src_root)/xsd/makefile) diff --git a/xsd/tests/cxx/parser/recursive/output b/xsd/tests/cxx/parser/recursive/output new file mode 100644 index 0000000..f26fb72 --- /dev/null +++ b/xsd/tests/cxx/parser/recursive/output @@ -0,0 +1,22 @@ +test::pre +test::name: testName +sub::pre +sub::name: subName +sub::pre +sub::name: sub-subName +sub::post +sub::sub +indir::pre +indir::name: sub-indirName +sub::pre +sub::name: sub-indir-subName +sub::post +indir::sub +indir::post +sub::pre +sub::name: sub-sub2Name +sub::post +sub::sub2 +sub::post +test::sub +test::post diff --git a/xsd/tests/cxx/parser/recursive/test.xml b/xsd/tests/cxx/parser/recursive/test.xml new file mode 100644 index 0000000..f6c219d --- /dev/null +++ b/xsd/tests/cxx/parser/recursive/test.xml @@ -0,0 +1,11 @@ +<test xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="test.xsd" + name="testName"> + <sub name="subName"> + <sub name="sub-subName"/> + <indir name="sub-indirName"> + <sub name="sub-indir-subName"/> + </indir> + <sub2 name="sub-sub2Name"/> + </sub> +</test> diff --git a/xsd/tests/cxx/parser/recursive/test.xsd b/xsd/tests/cxx/parser/recursive/test.xsd new file mode 100644 index 0000000..33e1d2d --- /dev/null +++ b/xsd/tests/cxx/parser/recursive/test.xsd @@ -0,0 +1,27 @@ +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> + + <xs:complexType name="sub_type"> + <xs:sequence> + <xs:element name="sub" type="sub_type" minOccurs="0"/> + <xs:element name="indir" type="indir_type" minOccurs="0"/> + <xs:element name="sub2" type="sub_type" minOccurs="0"/> + </xs:sequence> + <xs:attribute name="name" type="xs:string" /> + </xs:complexType> + + <xs:complexType name="indir_type"> + <xs:sequence> + <xs:element name="sub" type="sub_type" minOccurs="0"/> + </xs:sequence> + <xs:attribute name="name" type="xs:string" /> + </xs:complexType> + + <xs:complexType name="test_type"> + <xs:sequence> + <xs:element name="sub" type="sub_type" /> + </xs:sequence> + <xs:attribute name="name" type="xs:string" /> + </xs:complexType> + + <xs:element name="test" type="test_type" /> +</xs:schema> |