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/custom/comments/README | 57 ---------- examples/cxx/tree/custom/comments/dom-parse.cxx | 93 ---------------- examples/cxx/tree/custom/comments/dom-parse.hxx | 22 ---- examples/cxx/tree/custom/comments/driver.cxx | 90 --------------- examples/cxx/tree/custom/comments/makefile | 122 --------------------- examples/cxx/tree/custom/comments/people.xml | 20 ---- examples/cxx/tree/custom/comments/people.xsd | 29 ----- .../cxx/tree/custom/comments/xml-schema-custom.cxx | 117 -------------------- .../cxx/tree/custom/comments/xml-schema-custom.hxx | 57 ---------- 9 files changed, 607 deletions(-) delete mode 100644 examples/cxx/tree/custom/comments/README delete mode 100644 examples/cxx/tree/custom/comments/dom-parse.cxx delete mode 100644 examples/cxx/tree/custom/comments/dom-parse.hxx delete mode 100644 examples/cxx/tree/custom/comments/driver.cxx delete mode 100644 examples/cxx/tree/custom/comments/makefile delete mode 100644 examples/cxx/tree/custom/comments/people.xml delete mode 100644 examples/cxx/tree/custom/comments/people.xsd delete mode 100644 examples/cxx/tree/custom/comments/xml-schema-custom.cxx delete mode 100644 examples/cxx/tree/custom/comments/xml-schema-custom.hxx (limited to 'examples/cxx/tree/custom/comments') diff --git a/examples/cxx/tree/custom/comments/README b/examples/cxx/tree/custom/comments/README deleted file mode 100644 index 8fd69d0..0000000 --- a/examples/cxx/tree/custom/comments/README +++ /dev/null @@ -1,57 +0,0 @@ -This example shows how to customize the anyType XML Schema built-in -type to implement preservation of comments stored in XML documents. -Because anyType is a base type for every generated type, you can use -this technique to implement custom functionality that spans the -entire type system. For more information on the C++/Tree mapping -customization see the C++/Tree Mapping Customization Guide[2]. - -[2] http://wiki.codesynthesis.com/Tree/Customization_guide - -The example consists of the following files: - -people.xsd - XML Schema definition for a simple person record vocabulary. - -people.xml - Sample XML instance document. - -xml-schema.hxx - C++ types for XML Schema built-in types. This header file is generated - by XSD using the --generate-xml-schema option. The --custom-type option - is also used to customize the xsd:anyType type. - -people.hxx -people.ixx -people.cxx - C++ types that represent the person record vocabulary, a set of - parsing functions that convert XML instance documents to a tree-like - in-memory object model, and a set of serialization functions that - convert the object model back to XML. These are generated by XSD - from people.xsd with the --extern-xml-schema option in order to - include xml-schema.hxx. - -xml-schema-custom.hxx - Header file which defines our own xml_schema::type class. It is - included at the end of xml-schema.hxx using the --hxx-epilogue - option. - -xml-schema-custom.cxx - Source file which contains the implementation of our xml_schema:type - class. - -dom-parse.hxx -dom-parse.cxx - Definition and implementation of the parse() function that - parses an XML document to a DOM document while preserving - XML comments. - -driver.cxx - Driver for the example. It first calls the above parse() function - to parse the input file to a DOM document. It then parses the DOM - document to the object model and performs a number of modifications - on this object model. Finally, it serializes the modified object - model back to XML, including XML comments. - -To run the example on the sample XML instance document simply execute: - -$ ./driver people.xml diff --git a/examples/cxx/tree/custom/comments/dom-parse.cxx b/examples/cxx/tree/custom/comments/dom-parse.cxx deleted file mode 100644 index 9999f67..0000000 --- a/examples/cxx/tree/custom/comments/dom-parse.cxx +++ /dev/null @@ -1,93 +0,0 @@ -// file : examples/cxx/tree/custom/comments/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 ()); - - // Preserve comment nodes in the document. - // - conf->setParameter (XMLUni::fgDOMComments, true); - - // 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/custom/comments/dom-parse.hxx b/examples/cxx/tree/custom/comments/dom-parse.hxx deleted file mode 100644 index fea46d0..0000000 --- a/examples/cxx/tree/custom/comments/dom-parse.hxx +++ /dev/null @@ -1,22 +0,0 @@ -// file : examples/cxx/tree/custom/comments/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/custom/comments/driver.cxx b/examples/cxx/tree/custom/comments/driver.cxx deleted file mode 100644 index 39b16f7..0000000 --- a/examples/cxx/tree/custom/comments/driver.cxx +++ /dev/null @@ -1,90 +0,0 @@ -// file : examples/cxx/tree/custom/commens/driver.cxx -// copyright : not copyrighted - public domain - -#include // std::auto_ptr -#include -#include - -#include -#include - -#include "people.hxx" -#include "dom-parse.hxx" - -using namespace std; - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " people.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 (see below). - // - xercesc::XMLPlatformUtils::Initialize (); - - try - { - using namespace people; - namespace xml = xsd::cxx::xml; - - ifstream ifs; - ifs.exceptions (ifstream::badbit | ifstream::failbit); - ifs.open (argv[1]); - - // For performance reasons the internal XML to DOM parsing code - // discards comments in the resulting DOM document. To overcome - // this we are going to use our own parse() function from - // dom-parse.hxx that preserves comments in the resulting DOM - // documents. - // - xml_schema::dom::auto_ptr doc ( - parse (ifs, argv[1], true)); - - // Parse the DOM document to the object model. - // - std::auto_ptr c (catalog_ (*doc)); - - // Change the object model. - // - catalog::person_sequence& ps (c->person ()); - - for (catalog::person_iterator i (ps.begin ()); i != ps.end (); ++i) - { - i->age (i->age () + 1); - } - - person john ("John Doe", 30); - john.comment ("Record for John Doe"); - - ps.push_back (john); - - // Serialize. - // - xml_schema::namespace_infomap map; - - map["ppl"].name = "http://www.codesynthesis.com/people"; - map["ppl"].schema = "people.xsd"; - - catalog_ (std::cout, *c, map); - } - 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/custom/comments/makefile b/examples/cxx/tree/custom/comments/makefile deleted file mode 100644 index 478ab05..0000000 --- a/examples/cxx/tree/custom/comments/makefile +++ /dev/null @@ -1,122 +0,0 @@ -# file : examples/cxx/tree/custom/comments/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../build/bootstrap.make - -xsd := people.xsd -cxx := driver.cxx xml-schema-custom.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) - -# Header file for XML Schema namespace. -# -$(out_base)/xml-schema.hxx: $(out_root)/xsd/xsd - $(call message,xsd $(src_base)/xml-schema.xsd,\ -$(out_root)/xsd/xsd cxx-tree --output-dir $(out_base) --generate-xml-schema \ ---generate-serialization --custom-type anyType=/type_base \ ---hxx-epilogue '#include "xml-schema-custom.hxx"' xml-schema.xsd) - -# -# -genf := $(xsd:.xsd=.hxx) $(xsd:.xsd=.ixx) $(xsd:.xsd=.cxx) -gen := $(addprefix $(out_base)/,$(genf)) - -$(gen): xsd := $(out_root)/xsd/xsd -$(gen): xsd_options += \ ---generate-inline \ ---generate-serialization \ ---extern-xml-schema xml-schema.xsd - -$(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)/people.xsd,$(install_doc_dir)/xsd/$(path)/people.xsd) - $(call install-data,$(src_base)/people.xml,$(install_doc_dir)/xsd/$(path)/people.xml) - $(call install-data,$(src_base)/xml-schema-custom.hxx,$(install_doc_dir)/xsd/$(path)/xml-schema-custom.hxx) - $(call install-data,$(src_base)/xml-schema-custom.cxx,$(install_doc_dir)/xsd/$(path)/xml-schema-custom.cxx) - $(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)/people.xsd,$(dist_prefix)/$(path)/people.xsd) - $(call install-data,$(src_base)/people.xml,$(dist_prefix)/$(path)/people.xml) - $(call install-data,$(src_base)/xml-schema-custom.hxx,$(dist_prefix)/$(path)/xml-schema-custom.hxx) - $(call install-data,$(src_base)/xml-schema-custom.cxx,$(dist_prefix)/$(path)/xml-schema-custom.cxx) - $(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)) - $(call message,rm $$1,rm -f $$1,$(out_base)/xml-schema.hxx) - -# Generated .gitignore. -# -ifeq ($(out_base),$(src_base)) -$(gen): | $(out_base)/.gitignore -$(driver): | $(out_base)/.gitignore - -$(out_base)/.gitignore: files := driver xml-schema.hxx $(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/custom/comments/people.xml b/examples/cxx/tree/custom/comments/people.xml deleted file mode 100644 index 55c08a1..0000000 --- a/examples/cxx/tree/custom/comments/people.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - Joe Dirt - 28 - - - diff --git a/examples/cxx/tree/custom/comments/people.xsd b/examples/cxx/tree/custom/comments/people.xsd deleted file mode 100644 index e70dd2a..0000000 --- a/examples/cxx/tree/custom/comments/people.xsd +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/cxx/tree/custom/comments/xml-schema-custom.cxx b/examples/cxx/tree/custom/comments/xml-schema-custom.cxx deleted file mode 100644 index 67937d1..0000000 --- a/examples/cxx/tree/custom/comments/xml-schema-custom.cxx +++ /dev/null @@ -1,117 +0,0 @@ -// file : examples/cxx/tree/custom/comments/xml-schema-custom.cxx -// copyright : not copyrighted - public domain - -// Include xml-schema.hxx instead of xml-schema-custom.hxx here. -// -#include "xml-schema.hxx" - -#include -#include - -#include // xml::transcode, xml::string - -namespace xml = xsd::cxx::xml; - -namespace xml_schema -{ - type:: - type () - : type_base () - { - } - - type:: - type (const xercesc::DOMElement& e, flags f, container* c) - : type_base (e, f, c) - { - using namespace xercesc; - - // Here we are only handling a comment that is the first - // node in the element's content. - // - const DOMNode* n (e.getFirstChild ()); - - if (n != 0 && n->getNodeType () == DOMNode::COMMENT_NODE) - { - const DOMComment* c (static_cast (n)); - comment_ = xml::transcode (c->getData ()); - } - } - - type:: - type (const xercesc::DOMAttr& a, flags f, container* c) - : type_base (a, f, c) - { - // No comments for attributes. - // - } - - type:: - type (const std::string& s, const xercesc::DOMElement* e, - flags f, container* c) - : type_base (s, e, f, c) - { - // No comments for list items. - // - } - - type:: - type (const type& x, flags f, container* c) - : type_base (x, f, c), comment_ (x.comment_) - { - } - - type* type:: - _clone (flags f, container* c) const - { - return new type (*this, f, c); - } - - // Serialization operators. - // - void - operator<< (xercesc::DOMElement& e, const type& x) - { - // Call our base first. - // - const type_base& b (x); - e << b; - - // Add the comment if any. - // - const std::string s (x.comment ()); - - if (!s.empty ()) - { - using namespace xercesc; - - DOMDocument* doc (e.getOwnerDocument ()); - DOMComment* c (doc->createComment (xml::string (s).c_str ())); - e.appendChild (c); - } - } - - void - operator<< (xercesc::DOMAttr& a, const type& x) - { - // Call our base first. - // - const type_base& b (x); - a << b; - - // No comments for attributes. - // - } - - void - operator<< (xml_schema::list_stream& ls, const type& x) - { - // Call our base first. - // - const type_base& b (x); - ls << b; - - // No comments for list items. - // - } -} diff --git a/examples/cxx/tree/custom/comments/xml-schema-custom.hxx b/examples/cxx/tree/custom/comments/xml-schema-custom.hxx deleted file mode 100644 index 0442a44..0000000 --- a/examples/cxx/tree/custom/comments/xml-schema-custom.hxx +++ /dev/null @@ -1,57 +0,0 @@ -// file : examples/cxx/tree/custom/comments/xml-schema-custom.hxx -// copyright : not copyrighted - public domain - -// Do not include this file directly, use xml-schema.hxx instead. This -// file is included into generated xml-schema.hxx so we do not need to -// guard against multiple inclusions. -// - -#include - -namespace xml_schema -{ - // When customizing anyType always inherit from the original type. - // - class type: public type_base - { - public: - type (); - type (const xercesc::DOMElement&, flags = 0, container* = 0); - type (const xercesc::DOMAttr&, flags = 0, container* = 0); - type (const std::string&, const xercesc::DOMElement*, - flags = 0, container* = 0); - type (const type&, flags = 0, container* = 0); - - virtual type* - _clone (flags = 0, container* = 0) const; - - public: - // Comment manipulation API. - // - const std::string& - comment () const - { - return comment_; - } - - void - comment (const std::string& c) - { - comment_ = c; - } - - private: - std::string comment_; - }; - - // New serialization operators. - // - void - operator<< (xercesc::DOMElement&, const type&); - - void - operator<< (xercesc::DOMAttr&, const type&); - - void - operator<< (xml_schema::list_stream&, const type&); -} -- cgit v1.1