diff options
author | Jörg Frings-Fürst <debian@jff.email> | 2024-03-06 10:24:11 +0100 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff.email> | 2024-03-06 10:24:11 +0100 |
commit | 4538829ab86b5a1cd4e845e7eab165029c9d6d46 (patch) | |
tree | bbadf39aed0610c8f8f7b41fefff47773b8ac205 /xsd/examples/cxx/parser/polymorphism | |
parent | 23d41842168ac1a1580111b9c5c73500ceee3d57 (diff) | |
parent | aad5ad9bf0c02aa4e79bc6b7d6c934612fff4026 (diff) |
Update upstream source from tag 'upstream/4.2.0'
Update to upstream version '4.2.0'
with Debian dir 1b38df7bbcf313223de3c50107ac0255090fe647
Diffstat (limited to 'xsd/examples/cxx/parser/polymorphism')
-rw-r--r-- | xsd/examples/cxx/parser/polymorphism/README | 30 | ||||
-rw-r--r-- | xsd/examples/cxx/parser/polymorphism/driver.cxx | 70 | ||||
-rw-r--r-- | xsd/examples/cxx/parser/polymorphism/makefile | 106 | ||||
-rw-r--r-- | xsd/examples/cxx/parser/polymorphism/supermen-pimpl.cxx | 85 | ||||
-rw-r--r-- | xsd/examples/cxx/parser/polymorphism/supermen-pimpl.hxx | 68 | ||||
-rw-r--r-- | xsd/examples/cxx/parser/polymorphism/supermen.xml | 25 | ||||
-rw-r--r-- | xsd/examples/cxx/parser/polymorphism/supermen.xsd | 48 |
7 files changed, 0 insertions, 432 deletions
diff --git a/xsd/examples/cxx/parser/polymorphism/README b/xsd/examples/cxx/parser/polymorphism/README deleted file mode 100644 index 60a97e9..0000000 --- a/xsd/examples/cxx/parser/polymorphism/README +++ /dev/null @@ -1,30 +0,0 @@ -This example shows how to handle XML Schema polymorphism features such -as xsi:type attributes and substitution groups in the C++/Parser mapping. -The case when xsi:type is used on root elements is covered in the -polyroot examples. - -The example consists of the following files: - -supermen.xsd - XML Schema which describes the "supermen" instance documents. - -supermen.xml - Sample XML instance document. - -supermen-pskel.hxx -supermen-pskel.cxx - Parser skeletons generated by the XSD compiler from supermen.xsd. - Note the use of the --generate-polymorphic command line option. - -supermen-pimpl.hxx -supermen-pimpl.cxx - Parser implementations that print the XML data to STDOUT. - -driver.cxx - Driver for the example. It first constructs a parser instance from - all the individual parsers found in supermen-pimpl.hxx. It then invokes - this parser instance to parse the input file. - -To run the example on the sample XML instance document simply execute: - -$ ./driver supermen.xml diff --git a/xsd/examples/cxx/parser/polymorphism/driver.cxx b/xsd/examples/cxx/parser/polymorphism/driver.cxx deleted file mode 100644 index ffbe48b..0000000 --- a/xsd/examples/cxx/parser/polymorphism/driver.cxx +++ /dev/null @@ -1,70 +0,0 @@ -// file : examples/cxx/parser/polymorphism/driver.cxx -// copyright : not copyrighted - public domain - -#include <iostream> - -#include "supermen-pimpl.hxx" - -using std::cerr; -using std::endl; - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " supermen.xml" << endl; - return 1; - } - - try - { - // Construct the parser. - // - xml_schema::string_pimpl string_p; - xml_schema::boolean_pimpl boolean_p; - xml_schema::unsigned_int_pimpl unsigned_int_p; - - person_pimpl person_p; - superman_pimpl superman_p; - batman_pimpl batman_p; - - xml_schema::parser_map_impl person_map; - - supermen_pimpl supermen_p; - - - person_p.parsers (string_p); - superman_p.parsers (string_p, boolean_p); - batman_p.parsers (string_p, boolean_p, unsigned_int_p); - - // Here we are specifying a parser map which containes several parsers - // that can be used to parse the person element. - // - person_map.insert (person_p); - person_map.insert (superman_p); - person_map.insert (batman_p); - - supermen_p.person_parser (person_map); - - // Parse the XML document. The last argument to the document's - // constructor indicates that we are parsing polymorphic XML - // documents. - // - xml_schema::document doc_p (supermen_p, "supermen", true); - - supermen_p.pre (); - doc_p.parse (argv[1]); - supermen_p.post_supermen (); - } - catch (const xml_schema::exception& e) - { - cerr << e << endl; - return 1; - } - catch (const std::ios_base::failure&) - { - cerr << argv[1] << ": unable to open or read failure" << endl; - return 1; - } -} diff --git a/xsd/examples/cxx/parser/polymorphism/makefile b/xsd/examples/cxx/parser/polymorphism/makefile deleted file mode 100644 index 8a89ab8..0000000 --- a/xsd/examples/cxx/parser/polymorphism/makefile +++ /dev/null @@ -1,106 +0,0 @@ -# file : examples/cxx/parser/polymorphism/makefile -# copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make - -xsd := supermen.xsd -cxx := driver.cxx supermen-pimpl.cxx - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=-pskel.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/driver -install := $(out_base)/.install -dist := $(out_base)/.dist -dist-win := $(out_base)/.dist-win -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$(out_base) -I$(src_base) -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-polymorphic -$(gen): $(out_root)/xsd/xsd - -$(call include-dep,$(dep),$(obj),$(gen)) - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Install & Dist. -# -dist-common := $(out_base)/.dist-common - -$(install) $(dist) $(dist-win) $(dist-common): path := $(subst $(src_root)/,,$(src_base)) - -$(install): - $(call install-data,$(src_base)/README,$(install_doc_dir)/xsd/$(path)/README) - $(call install-data,$(src_base)/driver.cxx,$(install_doc_dir)/xsd/$(path)/driver.cxx) - $(call install-data,$(src_base)/supermen.xsd,$(install_doc_dir)/xsd/$(path)/supermen.xsd) - $(call install-data,$(src_base)/supermen.xml,$(install_doc_dir)/xsd/$(path)/supermen.xml) - $(call install-data,$(src_base)/supermen-pimpl.hxx,$(install_doc_dir)/xsd/$(path)/supermen-pimpl.hxx) - $(call install-data,$(src_base)/supermen-pimpl.cxx,$(install_doc_dir)/xsd/$(path)/supermen-pimpl.cxx) - -$(dist-common): - $(call install-data,$(src_base)/driver.cxx,$(dist_prefix)/$(path)/driver.cxx) - $(call install-data,$(src_base)/supermen.xsd,$(dist_prefix)/$(path)/supermen.xsd) - $(call install-data,$(src_base)/supermen.xml,$(dist_prefix)/$(path)/supermen.xml) - $(call install-data,$(src_base)/supermen-pimpl.hxx,$(dist_prefix)/$(path)/supermen-pimpl.hxx) - $(call install-data,$(src_base)/supermen-pimpl.cxx,$(dist_prefix)/$(path)/supermen-pimpl.cxx) - -$(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,,todos $(dist_prefix)/$(path)/README.txt) - -# 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,$(bld_root)/install.make) -$(call include,$(scf_root)/xsd/parser/xsd-cxx.make) - - -# Dependencies. -# -$(call import,$(src_root)/xsd/makefile) diff --git a/xsd/examples/cxx/parser/polymorphism/supermen-pimpl.cxx b/xsd/examples/cxx/parser/polymorphism/supermen-pimpl.cxx deleted file mode 100644 index f4b3bc6..0000000 --- a/xsd/examples/cxx/parser/polymorphism/supermen-pimpl.cxx +++ /dev/null @@ -1,85 +0,0 @@ -// file : examples/cxx/parser/polymorphism/supermen-pimpl.cxx -// copyright : not copyrighted - public domain -// - -#include <iostream> - -#include "supermen-pimpl.hxx" - -using std::cout; -using std::endl; - -// person_pimpl -// -void person_pimpl:: -pre () -{ - cout << "starting to parse person" << endl; -} - -void person_pimpl:: -name (const std::string& v) -{ - cout << "name: " << v << endl; -} - -void person_pimpl:: -post_person () -{ - cout << "finished parsing person" << endl - << endl; -} - -// superman_pimpl -// -void superman_pimpl:: -pre () -{ - cout << "starting to parse superman" << endl; -} - -void superman_pimpl:: -can_fly (bool v) -{ - cout << "can-fly: " << v << endl; -} - -void superman_pimpl:: -post_person () -{ - post_superman (); -} - -void superman_pimpl:: -post_superman () -{ - cout << "finished parsing superman" << endl - << endl; -} - -// batman_pimpl -// -void batman_pimpl:: -pre () -{ - cout << "starting to parse batman" << endl; -} - -void batman_pimpl:: -wing_span (unsigned int v) -{ - cout << "wing-span: " << v << endl; -} - -void batman_pimpl:: -post_superman () -{ - post_batman (); -} - -void batman_pimpl:: -post_batman () -{ - cout << "finished parsing batman" << endl - << endl; -} diff --git a/xsd/examples/cxx/parser/polymorphism/supermen-pimpl.hxx b/xsd/examples/cxx/parser/polymorphism/supermen-pimpl.hxx deleted file mode 100644 index eaf81e5..0000000 --- a/xsd/examples/cxx/parser/polymorphism/supermen-pimpl.hxx +++ /dev/null @@ -1,68 +0,0 @@ -// file : examples/cxx/parser/polymorphism/supermen-pimpl.hxx -// copyright : not copyrighted - public domain - -#ifndef SUPERMEN_PIMPL_HXX -#define SUPERMEN_PIMPL_HXX - -#include "supermen-pskel.hxx" - -class person_pimpl: public virtual person_pskel -{ -public: - virtual void - pre (); - - virtual void - name (const std::string&); - - virtual void - post_person (); -}; - -class superman_pimpl: public virtual superman_pskel, - public person_pimpl -{ -public: - virtual void - pre (); - - virtual void - can_fly (bool); - - // By default, post_superman() calls post_person(). In case of - // polymorphic parsing we want the opposite: post_person() calls - // post_superman(). - // - virtual void - post_person (); - - virtual void - post_superman (); -}; - -class batman_pimpl: public virtual batman_pskel, - public superman_pimpl -{ -public: - virtual void - pre (); - - virtual void - wing_span (unsigned int); - - // By default, post_batman() calls post_superman(). In case of - // polymorphic parsing we want the opposite: post_superman() - // calls post_batman(). - // - virtual void - post_superman (); - - virtual void - post_batman (); -}; - -class supermen_pimpl: public supermen_pskel -{ -}; - -#endif // SUPERMEN_PIMPL_HXX diff --git a/xsd/examples/cxx/parser/polymorphism/supermen.xml b/xsd/examples/cxx/parser/polymorphism/supermen.xml deleted file mode 100644 index 15054fa..0000000 --- a/xsd/examples/cxx/parser/polymorphism/supermen.xml +++ /dev/null @@ -1,25 +0,0 @@ -<?xml version="1.0"?> - -<!-- - -file : examples/cxx/parser/polymorphism/supermen.xml -copyright : not copyrighted - public domain - ---> - -<supermen xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:noNamespaceSchemaLocation="supermen.xsd"> - - <person> - <name>John Doe</name> - </person> - - <superman can-fly="false"> - <name>James "007" Bond</name> - </superman> - - <superman can-fly="true" wing-span="10" xsi:type="batman"> - <name>Bruce Wayne</name> - </superman> - -</supermen> diff --git a/xsd/examples/cxx/parser/polymorphism/supermen.xsd b/xsd/examples/cxx/parser/polymorphism/supermen.xsd deleted file mode 100644 index c9029da..0000000 --- a/xsd/examples/cxx/parser/polymorphism/supermen.xsd +++ /dev/null @@ -1,48 +0,0 @@ -<?xml version="1.0"?> - -<!-- - -file : examples/cxx/parser/polymorphism/supermen.xsd -copyright : not copyrighted - public domain - ---> - -<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> - - <xsd:complexType name="person"> - <xsd:sequence> - <xsd:element name="name" type="xsd:string"/> - </xsd:sequence> - </xsd:complexType> - - <!-- substitution group root --> - <xsd:element name="person" type="person"/> - - - <xsd:complexType name="superman"> - <xsd:complexContent> - <xsd:extension base="person"> - <xsd:attribute name="can-fly" type="xsd:boolean" use="required"/> - </xsd:extension> - </xsd:complexContent> - </xsd:complexType> - - <xsd:element name="superman" type="superman" substitutionGroup="person"/> - - <xsd:complexType name="batman"> - <xsd:complexContent> - <xsd:extension base="superman"> - <xsd:attribute name="wing-span" type="xsd:unsignedInt" use="required"/> - </xsd:extension> - </xsd:complexContent> - </xsd:complexType> - - <xsd:complexType name="supermen"> - <xsd:sequence> - <xsd:element ref="person" maxOccurs="unbounded"/> - </xsd:sequence> - </xsd:complexType> - - <xsd:element name="supermen" type="supermen"/> - -</xsd:schema> |