From 5e527213a2430bb3018e5eebd909aef294edf9b5 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 18 Dec 2020 18:48:46 +0300 Subject: Switch to build2 --- examples/cxx/tree/multiroot/README | 45 ----------- examples/cxx/tree/multiroot/balance.xml | 16 ---- examples/cxx/tree/multiroot/deposit.xml | 17 ---- examples/cxx/tree/multiroot/dom-parse.cxx | 93 ---------------------- examples/cxx/tree/multiroot/dom-parse.hxx | 22 ------ examples/cxx/tree/multiroot/driver.cxx | 124 ------------------------------ examples/cxx/tree/multiroot/makefile | 108 -------------------------- examples/cxx/tree/multiroot/protocol.xsd | 50 ------------ examples/cxx/tree/multiroot/withdraw.xml | 17 ---- 9 files changed, 492 deletions(-) delete mode 100644 examples/cxx/tree/multiroot/README delete mode 100644 examples/cxx/tree/multiroot/balance.xml delete mode 100644 examples/cxx/tree/multiroot/deposit.xml delete mode 100644 examples/cxx/tree/multiroot/dom-parse.cxx delete mode 100644 examples/cxx/tree/multiroot/dom-parse.hxx delete mode 100644 examples/cxx/tree/multiroot/driver.cxx delete mode 100644 examples/cxx/tree/multiroot/makefile delete mode 100644 examples/cxx/tree/multiroot/protocol.xsd delete mode 100644 examples/cxx/tree/multiroot/withdraw.xml (limited to 'examples/cxx/tree/multiroot') diff --git a/examples/cxx/tree/multiroot/README b/examples/cxx/tree/multiroot/README deleted file mode 100644 index b742422..0000000 --- a/examples/cxx/tree/multiroot/README +++ /dev/null @@ -1,45 +0,0 @@ -This example shows how to handle XML vocabularies with multiple -root elements using the C++/Tree mapping. - -See also the messaging example for an alternative approach that -uses the element type and element map features of the C++/Tree -mapping. - -The example consists of the following files: - -protocol.xsd - XML Schema which defines a simple bank account protocol with - requests such as withdraw and deposit. - -balance.xml -withdraw.xml -deposit.xml - Sample XML instances for the protocol requests. - -protocol.hxx -protocol.cxx - C++ types that represent the given vocabulary and a set of - parsing functions that convert XML documents to a tree-like - in-memory object model. These are generated by XSD from - protocol.xsd. - -dom-parse.hxx -dom-parse.cxx - Definition and implementation of the parse() function that - parses an XML document to a DOM document. - -driver.cxx - Driver for the example. It first calls the above parse() function - to parse the input file to a DOM document. It then determines the - type of request being handled and calls the corresponding parsing - function that constructs the object model from this DOM document. - Finally, it prints the content of this object model to STDERR. - This example intentionally does not support the deposit request - to show how to handle unknown documents. - -To run the example on the sample XML request documents simply -execute: - -$ ./driver balance.xml -$ ./driver withdraw.xml -$ ./driver deposit.xml diff --git a/examples/cxx/tree/multiroot/balance.xml b/examples/cxx/tree/multiroot/balance.xml deleted file mode 100644 index 68b434a..0000000 --- a/examples/cxx/tree/multiroot/balance.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - 123456789 - - diff --git a/examples/cxx/tree/multiroot/deposit.xml b/examples/cxx/tree/multiroot/deposit.xml deleted file mode 100644 index 4d9449a..0000000 --- a/examples/cxx/tree/multiroot/deposit.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - 123456789 - 1000000 - - diff --git a/examples/cxx/tree/multiroot/dom-parse.cxx b/examples/cxx/tree/multiroot/dom-parse.cxx deleted file mode 100644 index 98fc82e..0000000 --- a/examples/cxx/tree/multiroot/dom-parse.cxx +++ /dev/null @@ -1,93 +0,0 @@ -// file : examples/cxx/tree/multiroot/dom-parse.cxx -// copyright : not copyrighted - public domain - -#include "dom-parse.hxx" - -#include - -#include -#include // chLatin_* -#include - -#include -#include - -#include -#include - -using namespace xercesc; -namespace xml = xsd::cxx::xml; -namespace tree = xsd::cxx::tree; - -xml::dom::auto_ptr -parse (std::istream& is, const std::string& id, bool validate) -{ - const XMLCh ls_id [] = {chLatin_L, chLatin_S, chNull}; - - // Get an implementation of the Load-Store (LS) interface. - // - DOMImplementation* impl ( - DOMImplementationRegistry::getDOMImplementation (ls_id)); - - xml::dom::auto_ptr parser ( - impl->createLSParser (DOMImplementationLS::MODE_SYNCHRONOUS, 0)); - - DOMConfiguration* conf (parser->getDomConfig ()); - - // Discard comment nodes in the document. - // - conf->setParameter (XMLUni::fgDOMComments, false); - - // Enable datatype normalization. - // - conf->setParameter (XMLUni::fgDOMDatatypeNormalization, true); - - // Do not create EntityReference nodes in the DOM tree. No - // EntityReference nodes will be created, only the nodes - // corresponding to their fully expanded substitution text - // will be created. - // - conf->setParameter (XMLUni::fgDOMEntities, false); - - // Perform namespace processing. - // - conf->setParameter (XMLUni::fgDOMNamespaces, true); - - // Do not include ignorable whitespace in the DOM tree. - // - conf->setParameter (XMLUni::fgDOMElementContentWhitespace, false); - - // Enable/Disable validation. - // - conf->setParameter (XMLUni::fgDOMValidate, validate); - conf->setParameter (XMLUni::fgXercesSchema, validate); - conf->setParameter (XMLUni::fgXercesSchemaFullChecking, false); - - // Xerces-C++ 3.1.0 is the first version with working multi import - // support. - // -#if _XERCES_VERSION >= 30100 - conf->setParameter (XMLUni::fgXercesHandleMultipleImports, true); -#endif - - // We will release the DOM document ourselves. - // - conf->setParameter (XMLUni::fgXercesUserAdoptsDOMDocument, true); - - // Set error handler. - // - tree::error_handler eh; - xml::dom::bits::error_handler_proxy ehp (eh); - conf->setParameter (XMLUni::fgDOMErrorHandler, &ehp); - - // Prepare input stream. - // - xml::sax::std_input_source isrc (is, id); - Wrapper4InputSource wrap (&isrc, false); - - xml::dom::auto_ptr doc (parser->parse (&wrap)); - - eh.throw_if_failed > (); - - return doc; -} diff --git a/examples/cxx/tree/multiroot/dom-parse.hxx b/examples/cxx/tree/multiroot/dom-parse.hxx deleted file mode 100644 index c2ab0fb..0000000 --- a/examples/cxx/tree/multiroot/dom-parse.hxx +++ /dev/null @@ -1,22 +0,0 @@ -// file : examples/cxx/tree/multiroot/dom-parse.hxx -// copyright : not copyrighted - public domain - -#ifndef DOM_PARSE -#define DOM_PARSE - -#include -#include - -#include -#include - -// Parse an XML document from the standard input stream with an -// optional resource id. Resource id is used in diagnostics as -// well as to locate schemas referenced from inside the document. -// -xsd::cxx::xml::dom::auto_ptr -parse (std::istream& is, - const std::string& id, - bool validate); - -#endif // DOM_PARSE diff --git a/examples/cxx/tree/multiroot/driver.cxx b/examples/cxx/tree/multiroot/driver.cxx deleted file mode 100644 index 9497ef1..0000000 --- a/examples/cxx/tree/multiroot/driver.cxx +++ /dev/null @@ -1,124 +0,0 @@ -// file : examples/cxx/tree/multiroot/driver.cxx -// copyright : not copyrighted - public domain - -#include // std::auto_ptr -#include -#include -#include - -#include -#include - -#include // xml::transcode - -#include "dom-parse.hxx" - -#include "protocol.hxx" - -using namespace std; -using namespace protocol; - -// Parse an XML document and return a pointer to request_t which can -// then be tested with dynamic_cast. If your vocabulary does not have -// a common base type for all root element types then you can use -// xml_schema::type which is a base for all generated types. -// -auto_ptr -parse (istream& is, const string& id) -{ - using namespace xercesc; - namespace xml = xsd::cxx::xml; - - // Parse an XML instance to a DOM document using the parse() - // function from dom-parse.hxx. - // - xml_schema::dom::auto_ptr doc (parse (is, id, true)); - - DOMElement* root (doc->getDocumentElement ()); - - string ns (xml::transcode (root->getNamespaceURI ())); - string name (xml::transcode (root->getLocalName ())); - - auto_ptr r; - - // We could have handled the result directly in this function - // instead of returning it as an opaque pointer and using - // dynamic_cast later to figure out which request we are dealing - // with. - // - if (ns == "http://www.codesynthesis.com/protocol") - { - if (name == "balance") - { - // Use the balance parsing function. - // - r.reset (balance (*doc).release ()); - } - else if (name == "withdraw") - { - // Use the withdraw parsing function. - // - r.reset (withdraw (*doc).release ()); - } - } - - if (r.get () == 0) - cerr << "ignoring unknown request: " << ns << "#" << name << endl; - - return r; -} - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " request.xml" << endl; - return 1; - } - - int r (0); - - // We need to initialize the Xerces-C++ runtime because we - // are doing the XML-to-DOM parsing ourselves. - // - xercesc::XMLPlatformUtils::Initialize (); - - try - { - ifstream ifs; - ifs.exceptions (ifstream::badbit | ifstream::failbit); - ifs.open (argv[1]); - - auto_ptr r (parse (ifs, argv[1])); - - // Let's print what we've got. - // - if (balance_t* b = dynamic_cast (r.get ())) - { - cerr << "balance request for acc# " << b->account () << endl; - } - else if (withdraw_t* w = dynamic_cast (r.get ())) - { - cerr << "withdrawal request for acc# " << w->account () << ", " - << "amount: " << w->amount () << endl; - } - else - { - cerr << "unknown request" << endl; - } - } - catch (const xml_schema::exception& e) - { - cerr << e << endl; - r = 1; - } - catch (const std::ios_base::failure&) - { - cerr << argv[1] << ": unable to open or read failure" << endl; - r = 1; - } - - xercesc::XMLPlatformUtils::Terminate (); - return r; -} diff --git a/examples/cxx/tree/multiroot/makefile b/examples/cxx/tree/multiroot/makefile deleted file mode 100644 index 55c473a..0000000 --- a/examples/cxx/tree/multiroot/makefile +++ /dev/null @@ -1,108 +0,0 @@ -# file : examples/cxx/tree/multiroot/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make - -xsd := protocol.xsd -cxx := driver.cxx dom-parse.cxx - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=.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=.hxx) $(xsd:.xsd=.ixx) $(xsd:.xsd=.cxx) -gen := $(addprefix $(out_base)/,$(genf)) - -$(gen): xsd := $(out_root)/xsd/xsd -$(gen): xsd_options += --root-element-all -$(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)/protocol.xsd,$(install_doc_dir)/xsd/$(path)/protocol.xsd) - $(call install-data,$(src_base)/balance.xml,$(install_doc_dir)/xsd/$(path)/balance.xml) - $(call install-data,$(src_base)/deposit.xml,$(install_doc_dir)/xsd/$(path)/deposit.xml) - $(call install-data,$(src_base)/withdraw.xml,$(install_doc_dir)/xsd/$(path)/withdraw.xml) - $(call install-data,$(src_base)/dom-parse.hxx,$(install_doc_dir)/xsd/$(path)/dom-parse.hxx) - $(call install-data,$(src_base)/dom-parse.cxx,$(install_doc_dir)/xsd/$(path)/dom-parse.cxx) - -$(dist-common): - $(call install-data,$(src_base)/driver.cxx,$(dist_prefix)/$(path)/driver.cxx) - $(call install-data,$(src_base)/protocol.xsd,$(dist_prefix)/$(path)/protocol.xsd) - $(call install-data,$(src_base)/balance.xml,$(dist_prefix)/$(path)/balance.xml) - $(call install-data,$(src_base)/deposit.xml,$(dist_prefix)/$(path)/deposit.xml) - $(call install-data,$(src_base)/withdraw.xml,$(dist_prefix)/$(path)/withdraw.xml) - $(call install-data,$(src_base)/dom-parse.hxx,$(dist_prefix)/$(path)/dom-parse.hxx) - $(call install-data,$(src_base)/dom-parse.cxx,$(dist_prefix)/$(path)/dom-parse.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=.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/tree/xsd-cxx.make) - -# Dependencies. -# -$(call import,$(src_root)/xsd/makefile) diff --git a/examples/cxx/tree/multiroot/protocol.xsd b/examples/cxx/tree/multiroot/protocol.xsd deleted file mode 100644 index 1121824..0000000 --- a/examples/cxx/tree/multiroot/protocol.xsd +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/cxx/tree/multiroot/withdraw.xml b/examples/cxx/tree/multiroot/withdraw.xml deleted file mode 100644 index 8f1dc54..0000000 --- a/examples/cxx/tree/multiroot/withdraw.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - 123456789 - 1000000 - - -- cgit v1.1