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/binary/xdr/README | 34 ------- examples/cxx/tree/binary/xdr/driver.cxx | 148 ------------------------------- examples/cxx/tree/binary/xdr/library.xml | 52 ----------- examples/cxx/tree/binary/xdr/library.xsd | 75 ---------------- examples/cxx/tree/binary/xdr/makefile | 113 ----------------------- 5 files changed, 422 deletions(-) delete mode 100644 examples/cxx/tree/binary/xdr/README delete mode 100644 examples/cxx/tree/binary/xdr/driver.cxx delete mode 100644 examples/cxx/tree/binary/xdr/library.xml delete mode 100644 examples/cxx/tree/binary/xdr/library.xsd delete mode 100644 examples/cxx/tree/binary/xdr/makefile (limited to 'examples/cxx/tree/binary/xdr') diff --git a/examples/cxx/tree/binary/xdr/README b/examples/cxx/tree/binary/xdr/README deleted file mode 100644 index 22d5693..0000000 --- a/examples/cxx/tree/binary/xdr/README +++ /dev/null @@ -1,34 +0,0 @@ -This example shows how to save/load the object model to/from XDR -(eXternal Data Representation) binary format using XDR streams. -The XDR API is available out of the box on most UNIX and GNU/Linux -systems as part of Sun RPC. On Windows you may need to install a -third-party library which provides the XDR API. - -The example consists of the following files: - -library.xsd - XML Schema which describes a library of books. - -library.xml - Sample XML instance document. - -library.hxx -library.cxx - C++ types that represent the given vocabulary as well as data - representation stream insertion and extraction operations. These - are generated by XSD from library.xsd. Note that the - --generate-insertion and --generate-extraction options are used - to generate the insertion and extraction operations for XDR - stream. - -driver.cxx - Driver for the example. It first calls one of the parsing functions - that constructs the object model from the input XML file. It then - saves the object model to the XDR representation and loads it back. - Additionally, it prints the content of the object model before saving - it to the XDR representation and after loading it from the XDR - representation. - -To run the example on the sample XML instance document simply execute: - -$ ./driver library.xml diff --git a/examples/cxx/tree/binary/xdr/driver.cxx b/examples/cxx/tree/binary/xdr/driver.cxx deleted file mode 100644 index d109322..0000000 --- a/examples/cxx/tree/binary/xdr/driver.cxx +++ /dev/null @@ -1,148 +0,0 @@ -// file : examples/cxx/tree/binary/xdr/driver.cxx -// copyright : not copyrighted - public domain - -#include // std::auto_ptr -#include // std::memcpy -#include // std::size_t -#include - -#include -#include - -#include "library.hxx" - -using std::cerr; -using std::endl; -using std::size_t; - -// XDR output functions. Their implementations are provided after main(). -// -struct underflow_info -{ - xml_schema::buffer* buf; - size_t pos; -}; - -extern "C" int -overflow (void* user_data, char* buf, int n); - -extern "C" int -underflow (void* user_data, char* buf, int n); - -// The xdrrec_create function (used below) has slightly different -// prototypes on different platforms. To make this example portable -// we will need to cast the actual function to the following common -// prototype. -// -extern "C" -typedef void (*xdrrec_create_p) ( - XDR*, - unsigned int write_size, - unsigned int read_size, - void* user_data, - int (*read) (void* user_data, char* buf, int n), - int (*write) (void* user_data, char* buf, int n)); - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " library.xml" << endl; - return 1; - } - - try - { - using namespace library; - - xdrrec_create_p xdrrec_create_ = - reinterpret_cast (::xdrrec_create); - - // Read in the file. - // - std::auto_ptr c (catalog_ (argv[1])); - - cerr << *c << endl; - - // Save to an XDR stream. - // - XDR xdr; - xml_schema::buffer buf; - - xdrrec_create_ (&xdr, 0, 0, reinterpret_cast (&buf), 0, &overflow); - xdr.x_op = XDR_ENCODE; - - xml_schema::ostream oxdr (xdr); - - oxdr << *c; - - xdrrec_endofrecord (&xdr, true); // Flush the data. - xdr_destroy (&xdr); - - // The binary representation is now in the memory buffer 'buf'. - // To get to the raw data use buf.data() and buf.size(). - // - cerr << endl - << "binary representation size: " << buf.size () << endl; - - // Load from an XDR stream. - // - underflow_info ui; - ui.buf = &buf; - ui.pos = 0; - - xdrrec_create_ (&xdr, 0, 0, reinterpret_cast (&ui), &underflow, 0); - xdr.x_op = XDR_DECODE; - - xdrrec_skiprecord (&xdr); - - xml_schema::istream ixdr (xdr); - - std::auto_ptr copy (new catalog (ixdr)); - - xdr_destroy (&xdr); - - cerr << *copy << endl; - } - catch (const xml_schema::exception& e) - { - cerr << e << endl; - return 1; - } -} - -extern "C" int -overflow (void* p, char* buf, int n_) -{ - xml_schema::buffer* dst (reinterpret_cast (p)); - size_t n (static_cast (n_)); - - size_t size (dst->size ()); - size_t capacity (dst->capacity ()); - - // Implement exponential growth. - // - if (size + n > capacity && size + n < capacity * 2) - dst->capacity (capacity * 2); - - dst->size (size + n); - std::memcpy (dst->data () + size, buf, n); - - return n; -} - -extern "C" int -underflow (void* p, char* buf, int n_) -{ - underflow_info* ui (reinterpret_cast (p)); - size_t n (static_cast (n_)); - - size_t size (ui->buf->size () - ui->pos); - n = size > n ? n : size; - - std::memcpy (buf, ui->buf->data () + ui->pos, n); - ui->pos += n; - - return n; -} diff --git a/examples/cxx/tree/binary/xdr/library.xml b/examples/cxx/tree/binary/xdr/library.xml deleted file mode 100644 index dab6afb..0000000 --- a/examples/cxx/tree/binary/xdr/library.xml +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - - 0679760806 - The Master and Margarita - fiction - - - Mikhail Bulgakov - 1891-05-15 - 1940-03-10 - - - - - - 0679600841 - War and Peace - history - - - Leo Tolstoy - 1828-09-09 - 1910-11-20 - - - - - - 0679420290 - Crime and Punishment - philosophy - - - Fyodor Dostoevsky - 1821-11-11 - 1881-02-09 - - - - diff --git a/examples/cxx/tree/binary/xdr/library.xsd b/examples/cxx/tree/binary/xdr/library.xsd deleted file mode 100644 index 7513e3b..0000000 --- a/examples/cxx/tree/binary/xdr/library.xsd +++ /dev/null @@ -1,75 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/cxx/tree/binary/xdr/makefile b/examples/cxx/tree/binary/xdr/makefile deleted file mode 100644 index 77a9249..0000000 --- a/examples/cxx/tree/binary/xdr/makefile +++ /dev/null @@ -1,113 +0,0 @@ -# file : examples/cxx/tree/binary/xdr/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../build/bootstrap.make - -xsd := library.xsd -cxx := driver.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) -lnsl - -$(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 += --generate-ostream \ ---generate-insertion XDR --generate-extraction XDR -$(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)/library.xsd,$(install_doc_dir)/xsd/$(path)/library.xsd) - $(call install-data,$(src_base)/library.xml,$(install_doc_dir)/xsd/$(path)/library.xml) - -$(dist-common): - $(call install-data,$(src_base)/driver.cxx,$(dist_prefix)/$(path)/driver.cxx) - $(call install-data,$(src_base)/library.xsd,$(dist_prefix)/$(path)/library.xsd) - $(call install-data,$(src_base)/library.xml,$(dist_prefix)/$(path)/library.xml) - -$(dist): $(dist-common) - $(call install-data,$(src_base)/README,$(dist_prefix)/$(path)/README) - -$(dist-win): |$(out_root)/.dist-pre -$(dist-win): $(dist-common) - $(call install-data,$(src_base)/README,$(dist_prefix)/$(path)/README.txt) - $(call message,,todos $(dist_prefix)/$(path)/README.txt) - $(call meta-vc8sln,$(src_root)/dist/template-vc8.sln,xdr-vc8.sln) - $(call meta-vc9sln,$(src_root)/dist/template-vc9.sln,xdr-vc9.sln) - $(call meta-vc10sln,$(src_root)/dist/template-vc10.sln,xdr-vc10.sln) - $(call meta-vc11sln,$(src_root)/dist/template-vc11.sln,xdr-vc11.sln) - $(call meta-vc12sln,$(src_root)/dist/template-vc12.sln,xdr-vc12.sln) - - -# 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,$(scf_root)/xsd/tree/xsd-cxx.make) - -$(call include,$(bld_root)/install.make) -$(call include,$(bld_root)/meta/vc8sln.make) -$(call include,$(bld_root)/meta/vc9sln.make) -$(call include,$(bld_root)/meta/vc10sln.make) -$(call include,$(bld_root)/meta/vc11sln.make) -$(call include,$(bld_root)/meta/vc12sln.make) - - -# Dependencies. -# -$(call import,$(src_root)/xsd/makefile) -- cgit v1.1