summaryrefslogtreecommitdiff
path: root/examples/cxx/tree/custom/contacts
diff options
context:
space:
mode:
Diffstat (limited to 'examples/cxx/tree/custom/contacts')
-rw-r--r--examples/cxx/tree/custom/contacts/README40
-rw-r--r--examples/cxx/tree/custom/contacts/contacts-custom.cxx50
-rw-r--r--examples/cxx/tree/custom/contacts/contacts-custom.hxx43
-rw-r--r--examples/cxx/tree/custom/contacts/contacts.xml20
-rw-r--r--examples/cxx/tree/custom/contacts/contacts.xsd31
-rw-r--r--examples/cxx/tree/custom/contacts/driver.cxx38
-rw-r--r--examples/cxx/tree/custom/contacts/makefile112
7 files changed, 0 insertions, 334 deletions
diff --git a/examples/cxx/tree/custom/contacts/README b/examples/cxx/tree/custom/contacts/README
deleted file mode 100644
index 072ede3..0000000
--- a/examples/cxx/tree/custom/contacts/README
+++ /dev/null
@@ -1,40 +0,0 @@
-This example shows how to map a user-defined XML Schema type to a custom
-C++ class. It presents the simple case where the customized type is not
-used as a base in the same schema. For the complex case see the taxonomy
-example. For more information on the C++/Tree mapping customization see
-the C++/Tree Mapping Customization Guide[1].
-
-[1] http://wiki.codesynthesis.com/Tree/Customization_guide
-
-The example consists of the following files:
-
-contacts.xsd
- XML Schema definition for a simple contacts database.
-
-contacts.xml
- Sample XML instance document.
-
-contacts.hxx
-contacts.ixx
-contacts.cxx
- C++ types that represent the given vocabulary and a set of parsing
- functions that convert XML instance documents to a tree-like in-memory
- object model. These are generated by XSD from contacts.xsd with the
- --custom-type option in order to customize the contact type.
-
-contacts-custom.hxx
- Header file which defines our own contact class by inheriting from the
- generated contact_base. It is included at the end of contacts.hxx using
- the --hxx-epilogue option.
-
-contacts-custom.cxx
- Source file which contains the implementation of our contact class.
-
-driver.cxx
- Driver for the example. It first calls one of the parsing functions
- that constructs the object model from the input file. It then prints
- the contacts to STDERR.
-
-To run the example on the sample XML instance document simply execute:
-
-$ ./driver contacts.xml
diff --git a/examples/cxx/tree/custom/contacts/contacts-custom.cxx b/examples/cxx/tree/custom/contacts/contacts-custom.cxx
deleted file mode 100644
index 8bb0e22..0000000
--- a/examples/cxx/tree/custom/contacts/contacts-custom.cxx
+++ /dev/null
@@ -1,50 +0,0 @@
-// file : examples/cxx/tree/custom/contacts/contacts-custom.cxx
-// copyright : not copyrighted - public domain
-
-#include <ostream>
-
-// Include contacts.hxx instead of contacts-custom.hxx here.
-//
-#include "contacts.hxx"
-
-namespace contacts
-{
- // We implement the following constructs by simply forwarding
- // to our base.
- //
- contact::
- contact (const name_type& n,
- const email_type& e,
- const phone_type& p)
- : contact_base (n, e, p)
- {
- }
-
- contact::
- contact (const xercesc::DOMElement& e,
- xml_schema::flags f,
- xml_schema::container* c)
- : contact_base (e, f, c)
- {
- }
-
- contact::
- contact (const contact& x,
- xml_schema::flags f,
- xml_schema::container* c)
- : contact_base (x, f, c)
- {
- }
-
- contact* contact::
- _clone (xml_schema::flags f, xml_schema::container* c) const
- {
- return new contact (*this, f, c);
- }
-
- void contact::
- print (std::ostream& os) const
- {
- os << name () << " e| " << email () << " t| " << phone () << std::endl;
- }
-}
diff --git a/examples/cxx/tree/custom/contacts/contacts-custom.hxx b/examples/cxx/tree/custom/contacts/contacts-custom.hxx
deleted file mode 100644
index 65d6244..0000000
--- a/examples/cxx/tree/custom/contacts/contacts-custom.hxx
+++ /dev/null
@@ -1,43 +0,0 @@
-// file : examples/cxx/tree/custom/contacts/contacts-custom.hxx
-// copyright : not copyrighted - public domain
-
-// Do not include this file directly, use contacts.hxx instead. This
-// file is included into generated contacts.hxx so we do not need to
-// guard against multiple inclusions.
-//
-
-#include <iosfwd> // std::ostream
-
-namespace contacts
-{
- class contact: public contact_base
- {
- // The following constructor signatures are copied from
- // contact_base except for the copy constructor and the
- // _clone function where we had to change the type from
- // contact_base to contact.
- //
- public:
- contact (const name_type&,
- const email_type&,
- const phone_type&);
-
- contact (const xercesc::DOMElement&,
- xml_schema::flags = 0,
- xml_schema::container* = 0);
-
- contact (const contact&,
- xml_schema::flags = 0,
- xml_schema::container* = 0);
-
- virtual contact*
- _clone (xml_schema::flags = 0,
- xml_schema::container* = 0) const;
-
- // Our customizations.
- //
- public:
- void
- print (std::ostream&) const;
- };
-}
diff --git a/examples/cxx/tree/custom/contacts/contacts.xml b/examples/cxx/tree/custom/contacts/contacts.xml
deleted file mode 100644
index 331e692..0000000
--- a/examples/cxx/tree/custom/contacts/contacts.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0"?>
-
-<!--
-
-file : examples/cxx/tree/custom/contacts/contacts.xml
-copyright : not copyrighted - public domain
-
--->
-
-<cts:catalog xmlns:cts="http://www.codesynthesis.com/contacts"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.codesynthesis.com/contacts contacts.xsd">
-
- <contact>
- <name>Joe Dirt</name>
- <email>joe@dirt.com</email>
- <phone>555 DIRT</phone>
- </contact>
-
-</cts:catalog>
diff --git a/examples/cxx/tree/custom/contacts/contacts.xsd b/examples/cxx/tree/custom/contacts/contacts.xsd
deleted file mode 100644
index d6110fe..0000000
--- a/examples/cxx/tree/custom/contacts/contacts.xsd
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0"?>
-
-<!--
-
-file : examples/cxx/tree/custom/contacts/contacts.xsd
-copyright : not copyrighted - public domain
-
--->
-
-<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- xmlns:cts="http://www.codesynthesis.com/contacts"
- targetNamespace="http://www.codesynthesis.com/contacts">
-
- <xsd:complexType name="contact">
- <xsd:sequence>
- <xsd:element name="name" type="xsd:string"/>
- <xsd:element name="email" type="xsd:string"/>
- <xsd:element name="phone" type="xsd:string"/>
- </xsd:sequence>
- </xsd:complexType>
-
- <xsd:complexType name="catalog">
- <xsd:sequence>
- <xsd:element name="contact" type="cts:contact" maxOccurs="unbounded"/>
- </xsd:sequence>
- </xsd:complexType>
-
-
- <xsd:element name="catalog" type="cts:catalog"/>
-
-</xsd:schema>
diff --git a/examples/cxx/tree/custom/contacts/driver.cxx b/examples/cxx/tree/custom/contacts/driver.cxx
deleted file mode 100644
index ae8a2da..0000000
--- a/examples/cxx/tree/custom/contacts/driver.cxx
+++ /dev/null
@@ -1,38 +0,0 @@
-// file : examples/cxx/tree/custom/contacts/driver.cxx
-// copyright : not copyrighted - public domain
-
-#include <memory> // std::auto_ptr
-#include <iostream>
-
-#include "contacts.hxx"
-
-using std::cerr;
-using std::endl;
-
-int
-main (int argc, char* argv[])
-{
- if (argc != 2)
- {
- cerr << "usage: " << argv[0] << " contacts.xml" << endl;
- return 1;
- }
-
- try
- {
- using namespace contacts;
-
- std::auto_ptr<catalog> c (catalog_ (argv[1]));
-
- for (catalog::contact_const_iterator i (c->contact ().begin ());
- i != c->contact ().end (); ++i)
- {
- i->print (cerr);
- }
- }
- catch (const xml_schema::exception& e)
- {
- cerr << e << endl;
- return 1;
- }
-}
diff --git a/examples/cxx/tree/custom/contacts/makefile b/examples/cxx/tree/custom/contacts/makefile
deleted file mode 100644
index 400b41d..0000000
--- a/examples/cxx/tree/custom/contacts/makefile
+++ /dev/null
@@ -1,112 +0,0 @@
-# file : examples/cxx/tree/custom/contacts/makefile
-# license : GNU GPL v2 + exceptions; see accompanying LICENSE file
-
-include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../build/bootstrap.make
-
-xsd := contacts.xsd
-cxx := driver.cxx contacts-custom.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
-
-# We have to double-escape '#' because the message function
-# (which is used in command scripts) expands things twice.
-#
-$(gen): xsd_options += \
---generate-inline \
---custom-type contact=/contact_base \
---hxx-epilogue '\#include "contacts-custom.hxx"'
-
-$(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)/contacts.xsd,$(install_doc_dir)/xsd/$(path)/contacts.xsd)
- $(call install-data,$(src_base)/contacts.xml,$(install_doc_dir)/xsd/$(path)/contacts.xml)
- $(call install-data,$(src_base)/contacts-custom.hxx,$(install_doc_dir)/xsd/$(path)/contacts-custom.hxx)
- $(call install-data,$(src_base)/contacts-custom.cxx,$(install_doc_dir)/xsd/$(path)/contacts-custom.cxx)
-
-$(dist-common):
- $(call install-data,$(src_base)/driver.cxx,$(dist_prefix)/$(path)/driver.cxx)
- $(call install-data,$(src_base)/contacts.xsd,$(dist_prefix)/$(path)/contacts.xsd)
- $(call install-data,$(src_base)/contacts.xml,$(dist_prefix)/$(path)/contacts.xml)
- $(call install-data,$(src_base)/contacts-custom.hxx,$(dist_prefix)/$(path)/contacts-custom.hxx)
- $(call install-data,$(src_base)/contacts-custom.cxx,$(dist_prefix)/$(path)/contacts-custom.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)