From a8ce5c380c69539fe0c7c62c397634d9d0c9fde2 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/parser/multiroot/README | 51 ------- examples/cxx/parser/multiroot/balance.xml | 16 --- examples/cxx/parser/multiroot/deposit.xml | 17 --- examples/cxx/parser/multiroot/driver.cxx | 161 ----------------------- examples/cxx/parser/multiroot/makefile | 112 ---------------- examples/cxx/parser/multiroot/protocol-pimpl.cxx | 46 ------- examples/cxx/parser/multiroot/protocol-pimpl.hxx | 48 ------- examples/cxx/parser/multiroot/protocol.hxx | 61 --------- examples/cxx/parser/multiroot/protocol.map | 11 -- examples/cxx/parser/multiroot/protocol.xsd | 50 ------- examples/cxx/parser/multiroot/withdraw.xml | 17 --- 11 files changed, 590 deletions(-) delete mode 100644 examples/cxx/parser/multiroot/README delete mode 100644 examples/cxx/parser/multiroot/balance.xml delete mode 100644 examples/cxx/parser/multiroot/deposit.xml delete mode 100644 examples/cxx/parser/multiroot/driver.cxx delete mode 100644 examples/cxx/parser/multiroot/makefile delete mode 100644 examples/cxx/parser/multiroot/protocol-pimpl.cxx delete mode 100644 examples/cxx/parser/multiroot/protocol-pimpl.hxx delete mode 100644 examples/cxx/parser/multiroot/protocol.hxx delete mode 100644 examples/cxx/parser/multiroot/protocol.map delete mode 100644 examples/cxx/parser/multiroot/protocol.xsd delete mode 100644 examples/cxx/parser/multiroot/withdraw.xml (limited to 'examples/cxx/parser/multiroot') diff --git a/examples/cxx/parser/multiroot/README b/examples/cxx/parser/multiroot/README deleted file mode 100644 index 041dfec..0000000 --- a/examples/cxx/parser/multiroot/README +++ /dev/null @@ -1,51 +0,0 @@ -This example shows how to handle XML vocabularies with multiple -root elements using the C++/Parser 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 - C++ types that describe the protocol requests. These are - hand-written. - -protocol.map - Type map. It maps XML Schema types defined in protocol.xsd - to the C++ types defined in protocol.hxx. - -protocol-pskel.hxx -protocol-pskel.cxx - Parser skeletons generated by XSD from protocol.xsd and - protocol.map. - -protocol-pimpl.hxx -protocol-pimpl.cxx - Parser implementations that construct the custom object - model from an XML instance using the types from protocol.hxx. - These are hand-written implementations of the parser skeletons - defined in protocol-pskel.hxx. - -driver.cxx - Driver for the example. It implements a custom document parser - that determines which request is being parsed and uses the - corresponding parser implementation. The document parser - intentionally does not support the deposit request to show - how to handle unknown documents. The driver first constructs - a parser instance from all the individual parsers found in - protocol-pimpl.hxx. In then invokes this parser instance to - parse the input file and produce the in-memory object model. - Finally, it prints the contents of the object model to STDERR. - -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/parser/multiroot/balance.xml b/examples/cxx/parser/multiroot/balance.xml deleted file mode 100644 index 71ed493..0000000 --- a/examples/cxx/parser/multiroot/balance.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - 123456789 - - diff --git a/examples/cxx/parser/multiroot/deposit.xml b/examples/cxx/parser/multiroot/deposit.xml deleted file mode 100644 index 70f0c77..0000000 --- a/examples/cxx/parser/multiroot/deposit.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - 123456789 - 1000000 - - diff --git a/examples/cxx/parser/multiroot/driver.cxx b/examples/cxx/parser/multiroot/driver.cxx deleted file mode 100644 index 3b32898..0000000 --- a/examples/cxx/parser/multiroot/driver.cxx +++ /dev/null @@ -1,161 +0,0 @@ -// file : examples/cxx/parser/multiroot/driver.cxx -// copyright : not copyrighted - public domain - -#include // std::auto_ptr -#include - -#include "protocol.hxx" -#include "protocol-pimpl.hxx" - -using std::cerr; -using std::endl; -using xml_schema::ro_string; - -namespace protocol -{ - // Customize the xml_schema::document object to handle our protocol - // vocabulary with multiple root elements. - // - class document: public xml_schema::document - { - public: - document (balance_pskel& balance_p, withdraw_pskel& withdraw_p) - : balance_p_ (balance_p), withdraw_p_ (withdraw_p) - { - } - - request* - result () - { - return result_.release (); - } - - protected: - // This function is called to obtain the root element type parser. - // If the returned pointed is 0 then the whole document content - // is ignored. The type argument is used to handle polymorphic - // XML documents and is not used in this example (see the polyroot - // example for more information on this argument). - // - virtual xml_schema::parser_base* - start_root_element (const ro_string& ns, - const ro_string& name, - const ro_string* /* type */) - { - if (ns == "http://www.codesynthesis.com/protocol") - { - if (name == "balance") - { - balance_p_.pre (); - - return &balance_p_; - } - else if (name == "withdraw") - { - balance_p_.pre (); - - return &withdraw_p_; - } - } - - cerr << "ignoring unknown request: " << ns << "#" << name << endl; - - return 0; - } - - // This function is called to indicate the completion of document - // parsing. The parser argument contains the pointer returned by - // start_root_element. - // - virtual void - end_root_element (const ro_string& /* ns */, - const ro_string& /* name */, - xml_schema::parser_base* parser) - { - // We could have handled the result directly in this function - // instead of storing it in the result_ variable. - // - if (parser == &balance_p_) - { - result_.reset (balance_p_.post_balance ()); - } - else if (parser == &withdraw_p_) - { - result_.reset (withdraw_p_.post_withdraw ()); - } - else - result_.reset (0); - } - - - private: - std::auto_ptr result_; - - balance_pskel& balance_p_; - withdraw_pskel& withdraw_p_; - }; -} - - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " request.xml" << endl; - return 1; - } - - try - { - using namespace protocol; - - // Construct the parser. - // - xml_schema::unsigned_int_pimpl unsigned_int_p; - - balance_pimpl balance_p; - withdraw_pimpl withdraw_p; - - balance_p.parsers (unsigned_int_p); // account - - withdraw_p.parsers (unsigned_int_p, // account - unsigned_int_p); // amount - - // Parse the XML instance document. - // - document doc_p (balance_p, withdraw_p); - - // pre() and post() will be called as part of the start_root_element() - // and end_root_element() calls. - // - doc_p.parse (argv[1]); - std::auto_ptr r (doc_p.result ()); - - // Let's print what we've got. - // - if (balance* b = dynamic_cast (r.get ())) - { - cerr << "balance request for acc# " << b->account () << endl; - } - else if (withdraw* 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; - return 1; - } - catch (const std::ios_base::failure&) - { - cerr << argv[1] << ": unable to open or read failure" << endl; - return 1; - } -} diff --git a/examples/cxx/parser/multiroot/makefile b/examples/cxx/parser/multiroot/makefile deleted file mode 100644 index a8557d6..0000000 --- a/examples/cxx/parser/multiroot/makefile +++ /dev/null @@ -1,112 +0,0 @@ -# file : examples/cxx/parser/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 protocol-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 += --type-map $(src_base)/protocol.map -$(gen): $(out_root)/xsd/xsd $(src_base)/protocol.map - -$(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)/protocol.map,$(install_doc_dir)/xsd/$(path)/protocol.map) - $(call install-data,$(src_base)/protocol.hxx,$(install_doc_dir)/xsd/$(path)/protocol.hxx) - $(call install-data,$(src_base)/protocol-pimpl.hxx,$(install_doc_dir)/xsd/$(path)/protocol-pimpl.hxx) - $(call install-data,$(src_base)/protocol-pimpl.cxx,$(install_doc_dir)/xsd/$(path)/protocol-pimpl.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)/protocol.map,$(dist_prefix)/$(path)/protocol.map) - $(call install-data,$(src_base)/protocol.hxx,$(dist_prefix)/$(path)/protocol.hxx) - $(call install-data,$(src_base)/protocol-pimpl.hxx,$(dist_prefix)/$(path)/protocol-pimpl.hxx) - $(call install-data,$(src_base)/protocol-pimpl.cxx,$(dist_prefix)/$(path)/protocol-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/examples/cxx/parser/multiroot/protocol-pimpl.cxx b/examples/cxx/parser/multiroot/protocol-pimpl.cxx deleted file mode 100644 index b5ec1b2..0000000 --- a/examples/cxx/parser/multiroot/protocol-pimpl.cxx +++ /dev/null @@ -1,46 +0,0 @@ -// file : examples/cxx/parser/multiroot/protocol-pimpl.cxx -// copyright : not copyrighted - public domain - -#include "protocol-pimpl.hxx" - -namespace protocol -{ - // request_pimpl - // - void request_pimpl:: - account (unsigned int account) - { - account_ = account; - } - - request* request_pimpl:: - post_request () - { - // This parser is never used directly. - // - return 0; - } - - // balance_pimpl - // - balance* balance_pimpl:: - post_balance () - { - return new balance (account_); - } - - // withdraw_pimpl - // - void withdraw_pimpl:: - amount (unsigned int amount) - { - amount_ = amount; - } - - withdraw* withdraw_pimpl:: - post_withdraw () - { - return new withdraw (account_, amount_); - } -} - diff --git a/examples/cxx/parser/multiroot/protocol-pimpl.hxx b/examples/cxx/parser/multiroot/protocol-pimpl.hxx deleted file mode 100644 index c0693cb..0000000 --- a/examples/cxx/parser/multiroot/protocol-pimpl.hxx +++ /dev/null @@ -1,48 +0,0 @@ -// file : examples/cxx/parser/multiroot/protocol-pimpl.hxx -// copyright : not copyrighted - public domain - -#ifndef PROTOCOL_PIMPL_HXX -#define PROTOCOL_PIMPL_HXX - -#include "protocol.hxx" -#include "protocol-pskel.hxx" - -namespace protocol -{ - class request_pimpl: public virtual request_pskel - { - public: - virtual void - account (unsigned int); - - virtual request* - post_request (); - - protected: - unsigned int account_; - }; - - class balance_pimpl: public virtual balance_pskel, - public request_pimpl - { - public: - virtual balance* - post_balance (); - }; - - class withdraw_pimpl: public virtual withdraw_pskel, - public request_pimpl - { - public: - virtual void - amount (unsigned int); - - virtual withdraw* - post_withdraw (); - - private: - unsigned int amount_; - }; -} - -#endif // PROTOCOL_PIMPL_HXX diff --git a/examples/cxx/parser/multiroot/protocol.hxx b/examples/cxx/parser/multiroot/protocol.hxx deleted file mode 100644 index bbf5b56..0000000 --- a/examples/cxx/parser/multiroot/protocol.hxx +++ /dev/null @@ -1,61 +0,0 @@ -// file : examples/cxx/parser/multiroot/protocol.hxx -// copyright : not copyrighted - public domain - -#ifndef PROTOCOL_HXX -#define PROTOCOL_HXX - -namespace protocol -{ - class request - { - public: - virtual - ~request () - { - } - - unsigned int - account () const - { - return account_; - } - - protected: - request (unsigned int account) - : account_ (account) - { - } - - private: - unsigned int account_; - }; - - class balance: public request - { - public: - balance (unsigned int account) - : request (account) - { - } - }; - - class withdraw: public request - { - public: - withdraw (unsigned int account, unsigned int amount) - : request (account), amount_ (amount) - { - } - - unsigned int - amount () const - { - return amount_; - } - - private: - unsigned int amount_; - }; -} - -#endif // PROTOCOL_HXX diff --git a/examples/cxx/parser/multiroot/protocol.map b/examples/cxx/parser/multiroot/protocol.map deleted file mode 100644 index 8d8ac9f..0000000 --- a/examples/cxx/parser/multiroot/protocol.map +++ /dev/null @@ -1,11 +0,0 @@ -# file : examples/cxx/parser/multiroot/protocol.map -# copyright : not copyrighted - public domain - -namespace http://www.codesynthesis.com/protocol ::protocol -{ - include "protocol.hxx"; - - request request*; - balance balance*; - withdraw withdraw*; -} diff --git a/examples/cxx/parser/multiroot/protocol.xsd b/examples/cxx/parser/multiroot/protocol.xsd deleted file mode 100644 index e0ecc29..0000000 --- a/examples/cxx/parser/multiroot/protocol.xsd +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/cxx/parser/multiroot/withdraw.xml b/examples/cxx/parser/multiroot/withdraw.xml deleted file mode 100644 index 6d5cb39..0000000 --- a/examples/cxx/parser/multiroot/withdraw.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - 123456789 - 1000000 - - -- cgit v1.1